Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSDocs for activity files #101

Merged
merged 12 commits into from
Aug 8, 2020
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ target/

# Don't include log files
*.log
frontend/docs/*
22 changes: 22 additions & 0 deletions frontend/.jsdoc.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"plugins": ["plugins/markdown"],
"recurseDepth": 10,
"opts": {
"recurse": true,
"destination": "./docs/"
},
"source": {
"include": ["src"],
"includePattern": ".+\\.js(doc|x)?$",
"excludePattern": "node_modules"
},
"sourceType": "module",
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc", "closure"]
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false
}
}
136 changes: 136 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"local": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"docs": "./node_modules/.bin/jsdoc src -r -c ./.jsdoc.conf.json -d docs"
},
"engines": {
"node": "10.x.x"
Expand All @@ -44,5 +45,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"jsdoc": "~3.6.5"
}
}
4 changes: 2 additions & 2 deletions frontend/src/components/Utils/filter-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export function getCleanedTextInput(rawInput, defaultValue) {
* TODO(#72 & #67): Remove 'remove empty fields' once there is better way to
* remove collaborators (#72) and there is email validation (#67).
*
* @param {!Array{string}} collaboratorEmailsArr Array of emails corresponding
* @param {!Array.<string>} collaboratorEmailsArr Array of emails corresponding
* to the collaborators of the trip (not including the trip creator email).
* @return {!Array{string}} Array of all collaborator uids (including trip
* @return {!Array.<string>} Array of all collaborator uids (including trip
* creator uid).
*/
export function getCollaboratorUidArray(collaboratorEmailArr) {
Expand Down
38 changes: 22 additions & 16 deletions frontend/src/components/Utils/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { firestore } from 'firebase';
* Format a timestamp (in milliseconds) into a pretty string with just the time.
* Example: '10:19 AM'.
*
* @param {int} msTimestamp Timestamp in milliseconds of desired date.
* @param {string} timezone Timezone in which to convert.
* @param {!number} msTimestamp Timestamp in milliseconds of desired date.
anan-ya-y marked this conversation as resolved.
Show resolved Hide resolved
* @param {string} [timezone='America/New_York']
* Timezone in which to convert (using underscores, not spaces).
* @return {string} Formatted time.
*/
export function timestampToTimeFormatted(msTimestamp, timezone = 'America/New_York') {
Expand All @@ -21,8 +22,9 @@ export function timestampToTimeFormatted(msTimestamp, timezone = 'America/New_Yo
* Format a timestamp (in milliseconds) into a pretty string with just the date.
* Example: 'Monday, January 19, 1970'.
*
* @param {int} msTimestamp Timestamp in milliseconds of desired date.
* @param {string} timezone Timezone in which to convert.
* @param {!number} msTimestamp Timestamp in milliseconds of desired date.
anan-ya-y marked this conversation as resolved.
Show resolved Hide resolved
* @param {string} [timezone='America/New_York']
* Timezone in which to convert (using underscores, not spaces).
* @return {string} Formatted time.
*/
export function timestampToDateFormatted(msTimestamp, timezone='America/New_York') {
Expand All @@ -36,8 +38,9 @@ export function timestampToDateFormatted(msTimestamp, timezone='America/New_York
* Format a timestamp (in milliseconds) into a pretty string.
* Example: 'Monday, January 19, 1970 02:48 AM PST'.
*
* @param {int} msTimestamp Timestamp in milliseconds of desired date.
* @param {string} timezone Timezone in which to convert.
* @param {!number} msTimestamp Timestamp in milliseconds of desired date.
anan-ya-y marked this conversation as resolved.
Show resolved Hide resolved
* @param {string} [timezone='America/New_York']
* Timezone in which to convert (using underscores, not spaces).
* @returns {string} Formatted time.
*/
export function timestampToFormatted(msTimestamp, timezone = 'America/New_York') {
Expand All @@ -51,7 +54,7 @@ export function timestampToFormatted(msTimestamp, timezone = 'America/New_York')
/**
* Return a Firestore Timestamp corresponding to the date in `dateStr`.
*
* @param {string} dateStr String containing a date in the form 'YYYY-MM-DD'.
* @param {!string} dateStr String containing a date in the form 'YYYY-MM-DD'.
anan-ya-y marked this conversation as resolved.
Show resolved Hide resolved
* @return {firestore.Timestamp} Firestore timestamp object created.
*/
export function getTimestampFromDateString(dateStr) {
Expand All @@ -67,7 +70,7 @@ export function getTimestampFromDateString(dateStr) {
/**
* Formats a Firestore timestamp into a date string in ISO format.
*
* @param {firestore.Timestamp} timestamp Firestore timestamp object.
* @param {!firestore.Timestamp} timestamp Firestore timestamp object.
* @return {string} ISO formatted date string: "YYYY-MM-DD or 2020-05-12".
*/
export function timestampToISOString(timestamp) {
Expand All @@ -77,8 +80,9 @@ export function timestampToISOString(timestamp) {
/**
* Returns all the time zones in a country (in displayable format).
*
* @param {string} countryName The name of the country for which to get the time zones.
* @param {?string} countryName The name of the country for which to get the time zones.
* @return {string[]} The list of time zones in the provided country.
* Null or unfamiliar values of `countryName` will return the list of all timezones.
*/
export function timezonesForCountry(countryName) {
let zones;
Expand All @@ -96,9 +100,10 @@ export function timezonesForCountry(countryName) {
/**
* Get a date in 'YYYY-MM-DD' format.
*
* @param {number} msTimestamp Timestamp, in milliseconds since epoch.
* @param {string} timezone The timezone which the string should be returned in.
* @param {!number} msTimestamp Timestamp, in milliseconds since epoch.
anan-ya-y marked this conversation as resolved.
Show resolved Hide resolved
* @param {string} [timezone=null] The timezone which the string should be returned in.
anan-ya-y marked this conversation as resolved.
Show resolved Hide resolved
* @return {string} The date in 'YYYY-MM-DD' format.
* A null value will return timezone in GMT.
*/
export function getISODate(msTimestamp, timezone=null) {
if (timezone === null) {
Expand All @@ -110,9 +115,10 @@ export function getISODate(msTimestamp, timezone=null) {
/**
* Get a time in 24-hour ('HH:mm') format.
*
* @param {number} msTimestamp Timestamp, in milliseconds since epoch.
* @param {string} timezone The timezone which the string should be returned in.
* @param {!number} msTimestamp Timestamp, in milliseconds since epoch.
* @param {string} [timezone=null] The timezone which the string should be returned in.
anan-ya-y marked this conversation as resolved.
Show resolved Hide resolved
* @return {string} The time in 24-hour (HH:mm) format.
* A null value will return timezone in GMT.
*/
export function get24hTime(msTimestamp, timezone = null) {
if (timezone === null) {
Expand All @@ -124,9 +130,9 @@ export function get24hTime(msTimestamp, timezone = null) {
/**
* Get a Firebase Timestamp object for time.
*
* @param {string} time The time in 'HH:mm' format.
* @param {string} date The date in 'YYYY-MM-DD' format.
* @param {string} tz The timezone in which the date takes place.
* @param {!string} time The time in 'HH:mm' format.
* @param {!string} date The date in 'YYYY-MM-DD' format.
* @param {!string} tz The timezone in which the date takes place.
* @return {firestore.Timestamp} Firestore timestamp object at the same time.
*/
export function firebaseTsFromISO(time, date, tz) {
Expand Down
Loading