Skip to content

Commit 3f1192a

Browse files
author
David Joy
committed
docs: fixing comment newlines
1 parent 5092ccc commit 3f1192a

File tree

4 files changed

+92
-32
lines changed

4 files changed

+92
-32
lines changed

src/config.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/**
2-
* The configuration module provides utilities for working with an application's configuration document (ConfigDocument). This module uses `process.env` to import configuration variables from the command-line build process. It can be dynamically extended at run-time using a `config` initialization handler. Please see the Initialization documentation for more information on handlers and initialization phases.
2+
* The configuration module provides utilities for working with an application's configuration
3+
* document (ConfigDocument). This module uses `process.env` to import configuration variables
4+
* from the command-line build process. It can be dynamically extended at run-time using a
5+
* `config` initialization handler. Please see the Initialization documentation for more
6+
* information on handlers and initialization phases.
37
*
48
* @module Config
59
*/
@@ -32,7 +36,9 @@ let config = {
3236
};
3337

3438
/**
35-
* Getter for the application configuration document. This is synchronous and merely returns a reference to an existing object, and is thus safe to call as often as desired. The document should have the following keys at a minimum:
39+
* Getter for the application configuration document. This is synchronous and merely returns a
40+
* reference to an existing object, and is thus safe to call as often as desired. The document
41+
* should have the following keys at a minimum:
3642
*
3743
* @memberof Config
3844
* @returns {ConfigDocument}
@@ -44,7 +50,8 @@ export function getConfig() {
4450
/**
4551
* Replaces the existing ConfigDocument. This is not commonly used, but can be helpful for tests.
4652
*
47-
* The supplied config document will be tested with `ensureDefinedConfig` to ensure it does not have any `undefined` keys.
53+
* The supplied config document will be tested with `ensureDefinedConfig` to ensure it does not
54+
* have any `undefined` keys.
4855
*
4956
* @memberof Config
5057
* @param {ConfigDocument} newConfig
@@ -56,7 +63,8 @@ export function setConfig(newConfig) {
5663
}
5764

5865
/**
59-
* Merges additional configuration values into the ConfigDocument returned by `getConfig`. Will override any values that exist with the same keys.
66+
* Merges additional configuration values into the ConfigDocument returned by `getConfig`. Will
67+
* override any values that exist with the same keys.
6068
*
6169
* ```
6270
* mergeConfig({
@@ -76,7 +84,12 @@ export function mergeConfig(newConfig) {
7684
}
7785

7886
/**
79-
* A method allowing application code to indicate that particular ConfigDocument keys are required for them to function. This is useful for diagnosing development/deployment issues, primarily, by surfacing misconfigurations early. For instance, if the build process fails to supply an environment variable on the command-line, it's possible that one of the `process.env` variables will be undefined. Should be used in conjunction with `mergeConfig` for custom `ConfigDocument` properties. Requester is for informational/error reporting purposes only.
87+
* A method allowing application code to indicate that particular ConfigDocument keys are required
88+
* for them to function. This is useful for diagnosing development/deployment issues, primarily,
89+
* by surfacing misconfigurations early. For instance, if the build process fails to supply an
90+
* environment variable on the command-line, it's possible that one of the `process.env` variables
91+
* will be undefined. Should be used in conjunction with `mergeConfig` for custom `ConfigDocument`
92+
* properties. Requester is for informational/error reporting purposes only.
8093
*
8194
* ```
8295
* ensureConfig(['LMS_BASE_URL', 'LOGIN_URL'], 'MySpecialComponent');
@@ -86,7 +99,10 @@ export function mergeConfig(newConfig) {
8699
* // if LOGIN_URL is undefined, for example.
87100
* ```
88101
*
89-
* *NOTE*: `ensureConfig` waits until `APP_CONFIG_INITIALIZED` is published to verify the existence of the specified properties. This means that this function is compatible with custom `config` phase handlers responsible for loading additional configuration data in the initialization sequence.
102+
* *NOTE*: `ensureConfig` waits until `APP_CONFIG_INITIALIZED` is published to verify the existence
103+
* of the specified properties. This means that this function is compatible with custom `config`
104+
* phase handlers responsible for loading additional configuration data in the initialization
105+
* sequence.
90106
*
91107
* @memberof Config
92108
* @param {Array} keys
@@ -114,7 +130,9 @@ export function ensureConfig(keys, requester = 'unspecified application code') {
114130
* }
115131
* ```
116132
*
117-
* When using Webpack (i.e., normal usage), the build process is responsible for supplying these variables via command-line environment variables. That means they must be supplied at build time.
133+
* When using Webpack (i.e., normal usage), the build process is responsible for supplying these
134+
* variables via command-line environment variables. That means they must be supplied at build
135+
* time.
118136
*
119137
* @name ConfigDocument
120138
* @property {string} ACCESS_TOKEN_COOKIE_NAME

src/initialize.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
2-
* The initialization module provides a function for managing an application's initialization lifecycle. It also provides constants and default handler implementations.
2+
* The initialization module provides a function for managing an application's initialization
3+
* lifecycle. It also provides constants and default handler implementations.
34
*
45
* @module Initialization
56
*/
@@ -27,7 +28,9 @@ export const APP_READY = `${APP_TOPIC}.READY`;
2728
export const APP_INIT_ERROR = `${APP_TOPIC}.INIT_ERROR`;
2829

2930
/**
30-
* A browser history object created by the [history](https://github.com/ReactTraining/history) package. Applications are encouraged to use this history object, rather than creating their own, as behavior may be undefined when managing history via multiple mechanisms/instances.
31+
* A browser history object created by the [history](https://github.com/ReactTraining/history)
32+
* package. Applications are encouraged to use this history object, rather than creating their own,
33+
* as behavior may be undefined when managing history via multiple mechanisms/instances.
3134
*
3235
* @memberof Utilities
3336
*/
@@ -48,10 +51,12 @@ export async function initError(error) {
4851
* The handler has several responsibilities:
4952
* - Determining the user's authentication state (authenticated or anonymous)
5053
* - Optionally redirecting to login if the application requires an authenticated user.
51-
* - Optionally loading additional user information via the application's user account data endpoint.
54+
* - Optionally loading additional user information via the application's user account data
55+
* endpoint.
5256
*
5357
* @memberof Initialization
54-
* @param {boolean} requireUser Whether or not we should redirect to login if a user is not authenticated.
58+
* @param {boolean} requireUser Whether or not we should redirect to login if a user is not
59+
* authenticated.
5560
* @param {boolean} hydrateUser Whether or not we should fetch additional user account data.
5661
*/
5762
export async function auth(requireUser, hydrateUser) {
@@ -73,7 +78,9 @@ export async function auth(requireUser, hydrateUser) {
7378
/**
7479
* The default handler for the initialization lifecycle's `analytics` phase.
7580
*
76-
* The handler is responsible for identifying authenticated and anonymous users with the analytics service. This is a pre-requisite for sending analytics events, thus, we do it during the initialization sequence so that analytics is ready once the application's UI code starts to load.
81+
* The handler is responsible for identifying authenticated and anonymous users with the analytics
82+
* service. This is a pre-requisite for sending analytics events, thus, we do it during the
83+
* initialization sequence so that analytics is ready once the application's UI code starts to load.
7784
*
7885
* @memberof Initialization
7986
*/
@@ -107,12 +114,23 @@ function applyOverrideHandlers(overrides) {
107114
*
108115
* @memberof Initialization
109116
* @param {Object} [options]
110-
* @param {*} [options.loggingService=NewRelicLoggingService] The `LoggingService` implementation to use.
111-
* @param {*} [options.analyticsService=SegmentAnalyticsService] The `AnalyticsService` implementation to use.
112-
* @param {*} [options.requireAuthenticatedUser=false] If true, turns on automatic login redirection for unauthenticated users. Defaults to false, meaning that by default the application will allow anonymous/unauthenticated sessions.
113-
* @param {*} [options.hydrateAuthenticatedUser=false] If true, makes an API call to the user account endpoint (`${App.config.LMS_BASE_URL}/api/user/v1/accounts/${username}`) to fetch detailed account information for the authenticated user. This data is merged into the return value of `getAuthenticatedUser`, overriding any duplicate keys that already exist. Defaults to false, meaning that no additional account information will be loaded.
114-
* @param {*} [options.messages] A i18n-compatible messages object, or an array of such objects. If an array is provided, duplicate keys are resolved with the last-one-in winning.
115-
* @param {*} [options.handlers={}] An optional object of handlers which can be used to replace the default behavior of any part of the startup sequence. It can also be used to add additional initialization behavior before or after the rest of the sequence.
117+
* @param {*} [options.loggingService=NewRelicLoggingService] The `LoggingService` implementation
118+
* to use.
119+
* @param {*} [options.analyticsService=SegmentAnalyticsService] The `AnalyticsService`
120+
* implementation to use.
121+
* @param {*} [options.requireAuthenticatedUser=false] If true, turns on automatic login
122+
* redirection for unauthenticated users. Defaults to false, meaning that by default the
123+
* application will allow anonymous/unauthenticated sessions.
124+
* @param {*} [options.hydrateAuthenticatedUser=false] If true, makes an API call to the user
125+
* account endpoint (`${App.config.LMS_BASE_URL}/api/user/v1/accounts/${username}`) to fetch
126+
* detailed account information for the authenticated user. This data is merged into the return
127+
* value of `getAuthenticatedUser`, overriding any duplicate keys that already exist. Defaults to
128+
* false, meaning that no additional account information will be loaded.
129+
* @param {*} [options.messages] A i18n-compatible messages object, or an array of such objects. If
130+
* an array is provided, duplicate keys are resolved with the last-one-in winning.
131+
* @param {*} [options.handlers={}] An optional object of handlers which can be used to replace the
132+
* default behavior of any part of the startup sequence. It can also be used to add additional
133+
* initialization behavior before or after the rest of the sequence.
116134
*/
117135
export async function initialize({
118136
loggingService = NewRelicLoggingService,

src/pubSub.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
/**
2-
* The PubSub module is a thin wrapper around the base functionality of [PubSubJS](https://github.com/mroderick/PubSubJS). For the sake of simplicity and not relying too heavily on implementation-specific features, it maintains a fairly simple API (subscribe, unsubscribe, and publish).
2+
* The PubSub module is a thin wrapper around the base functionality of
3+
* [PubSubJS](https://github.com/mroderick/PubSubJS). For the sake of simplicity and not relying
4+
* too heavily on implementation-specific features, it maintains a fairly simple API (subscribe,
5+
* unsubscribe, and publish).
36
*
4-
* Publish/Subscribe events should be used mindfully, especially in relation to application UI frameworks like React. Given React's unidirectional data flow and prop/state management capabilities, using a pub/sub mechanism is at odds with that framework's best practices.
7+
* Publish/Subscribe events should be used mindfully, especially in relation to application UI
8+
* frameworks like React. Given React's unidirectional data flow and prop/state management
9+
* capabilities, using a pub/sub mechanism is at odds with that framework's best practices.
510
*
6-
* That said, we use pub/sub in our application initialization sequence to allow applications to hook into the initialization lifecycle, and we also use them to publish when the application state has changed, i.e., when the config document or user's authentication state have changed.
11+
* That said, we use pub/sub in our application initialization sequence to allow applications to
12+
* hook into the initialization lifecycle, and we also use them to publish when the application
13+
* state has changed, i.e., when the config document or user's authentication state have changed.
714
*
815
* @module PubSub
916
*/

src/utils.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import camelCase from 'lodash.camelcase';
66
import snakeCase from 'lodash.snakecase';
77

88
/**
9-
* This is the underlying function used by camelCaseObject, snakeCaseObject, and convertKeyNames above.
9+
* This is the underlying function used by camelCaseObject, snakeCaseObject, and convertKeyNames
10+
* above.
1011
*
11-
* Given an object (or array) and a modification function, will perform the function on each key it encounters on the object and its tree of children.
12+
* Given an object (or array) and a modification function, will perform the function on each key it
13+
* encounters on the object and its tree of children.
1214
*
1315
* The modification function must take a string as an argument and returns a string.
1416
*
@@ -23,9 +25,11 @@ import snakeCase from 'lodash.snakecase';
2325
* }
2426
* ```
2527
*
26-
* This function will turn any key that matches 'edX' into 'Open edX'. All other keys will be passed through unmodified.
28+
* This function will turn any key that matches 'edX' into 'Open edX'. All other keys will be
29+
* passed through unmodified.
2730
*
28-
* Can accept arrays as well as objects, and will perform its conversion on any objects it finds in the array.
31+
* Can accept arrays as well as objects, and will perform its conversion on any objects it finds in
32+
* the array.
2933
*
3034
* @memberof Utilities
3135
* @param {Object} object
@@ -55,9 +59,13 @@ export function modifyObjectKeys(object, modify) {
5559
}
5660

5761
/**
58-
* Performs a deep conversion to camelCase on all keys in the provided object and its tree of children. Uses [lodash.camelcase](https://lodash.com/docs/4.17.15#camelCase) on each key. This is commonly used to convert snake_case keys in models from a backend server into camelCase keys for use in the JavaScript client.
62+
* Performs a deep conversion to camelCase on all keys in the provided object and its tree of
63+
* children. Uses [lodash.camelcase](https://lodash.com/docs/4.17.15#camelCase) on each key. This
64+
* is commonly used to convert snake_case keys in models from a backend server into camelCase keys
65+
* for use in the JavaScript client.
5966
*
60-
* Can accept arrays as well as objects, and will perform its conversion on any objects it finds in the array.
67+
* Can accept arrays as well as objects, and will perform its conversion on any objects it finds in
68+
* the array.
6169
*
6270
* @memberof Utilities
6371
* @param {Array|Object} object
@@ -68,9 +76,13 @@ export function camelCaseObject(object) {
6876
}
6977

7078
/**
71-
* Performs a deep conversion to snake_case on all keys in the provided object and its tree of children. Uses [lodash.snakecase](https://lodash.com/docs/4.17.15#snakeCase) on each key. This is commonly used to convert camelCase keys from the JavaScript app into snake_case keys expected by backend servers.
79+
* Performs a deep conversion to snake_case on all keys in the provided object and its tree of
80+
* children. Uses [lodash.snakecase](https://lodash.com/docs/4.17.15#snakeCase) on each key. This
81+
* is commonly used to convert camelCase keys from the JavaScript app into snake_case keys expected
82+
* by backend servers.
7283
*
73-
* Can accept arrays as well as objects, and will perform its conversion on any objects it finds in the array.
84+
* Can accept arrays as well as objects, and will perform its conversion on any objects it finds in
85+
* the array.
7486
*
7587
* @memberof Utilities
7688
* @param {Array|Object} object
@@ -81,7 +93,10 @@ export function snakeCaseObject(object) {
8193
}
8294

8395
/**
84-
* Given a map of key-value pairs, performs a deep conversion key names in the specified object _from_ the key _to_ the value. This is useful for updating names in an API request to the names used throughout a client application if they happen to differ. It can also be used in the reverse - formatting names from the client application to names expected by an API.
96+
* Given a map of key-value pairs, performs a deep conversion key names in the specified object
97+
* _from_ the key _to_ the value. This is useful for updating names in an API request to the names
98+
* used throughout a client application if they happen to differ. It can also be used in the
99+
* reverse - formatting names from the client application to names expected by an API.
85100
*
86101
* ```
87102
* import { convertKeyNames } from '@edx/frontend-base';
@@ -96,7 +111,8 @@ export function snakeCaseObject(object) {
96111
* console.log(result) // { their_key: 'my value' }
97112
* ```
98113
*
99-
* Can accept arrays as well as objects, and will perform its conversion on any objects it finds in the array.
114+
* Can accept arrays as well as objects, and will perform its conversion on any objects it finds in
115+
* the array.
100116
*
101117
* @memberof Utilities
102118
* @param {Array|Object} object
@@ -112,7 +128,8 @@ export function convertKeyNames(object, nameMap) {
112128

113129
/**
114130
* *Deprecated*: A method which converts the supplied query string into an object of
115-
key-value pairs and returns it. Defaults to the current query string - should perform like [window.searchParams](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams)
131+
* key-value pairs and returns it. Defaults to the current query string - should perform like
132+
* [window.searchParams](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams)
116133
*
117134
* @deprecated
118135
* @memberof Utilities

0 commit comments

Comments
 (0)