Skip to content

Commit a38f444

Browse files
authored
Add code docs formerly in the readme (#5)
* reinstate 2.12.5 and 2.13.0 * lint errors * adding a missing file * doc comments * cleanup * fix lint errors * fix lint errors * fix lint errors * undo a commit * undo a commit * add typedoc build (#6) * add typedoc build * add makefile * exclude test code * doc comment fixes * more code doc cleanup * minor doc update
1 parent 25978c6 commit a38f444

12 files changed

+289
-18
lines changed

.ldrelease/config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ template:
1111

1212
documentation:
1313
githubPages: true
14-
title: LaunchDarkly React SDK
1514

1615
sdk:
1716
displayName: "React"

docs/Makefile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
# This makefile can be run locally (cd docs && LD_RELEASE_VERSION=xxx make) but it will
3+
# also be run automatically when doing a release via Releaser.
4+
5+
ifeq (,${LD_RELEASE_VERSION})
6+
TITLE=LaunchDarkly React SDK
7+
else
8+
TITLE=LaunchDarkly React SDK (${LD_RELEASE_VERSION})
9+
endif
10+
11+
html:
12+
rm -rf build
13+
mkdir -p build/html
14+
# For unknown reasons, TypeDoc doesn't seem to work reliably in this project when we put our
15+
# configuration in typedoc.js (as we do in all our other JS projects). Therefore we'll just
16+
# put all the options on the command line.
17+
# Also for unknown reasons, TypeDoc does not like us to specify a source path of ./src even
18+
# though that's what we do in our other projects, so we'll cd to the project root.
19+
cd .. && ./node_modules/.bin/typedoc \
20+
--mode file \
21+
--out ./docs/build/html \
22+
--name "${TITLE}" \
23+
--exclude '**/*.test.ts*' \
24+
--excludeExternals \
25+
--externalPattern "**/node_modules/**" \
26+
--readme none
27+
28+
.PHONY: html

package-lock.json

+172
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"tslint": "^5.13.1",
5151
"tslint-config-prettier": "^1.18.0",
5252
"tslint-plugin-prettier": "^2.0.1",
53+
"typedoc": "0.14.2",
5354
"typescript": "^3.3.3333"
5455
},
5556
"dependencies": {

src/context.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,28 @@ interface LDContext {
1212
flags: LDFlagSet;
1313

1414
/**
15-
* The LaunchDarkly client's instance interface. This will be be undefined initially until
16-
* initialization is complete.
15+
* An instance of `LDClient` from the LaunchDarkly JS SDK (`launchdarkly-js-client-sdk`).
16+
* This will be be undefined initially until initialization is complete.
1717
*
1818
* @see http://docs.launchdarkly.com/docs/js-sdk-reference
1919
*/
2020
ldClient?: LDClient;
2121
}
2222

23+
/**
24+
* @ignore
25+
*/
2326
const context = createContext<LDContext>({ flags: {}, ldClient: undefined });
24-
const { Provider, Consumer } = context;
27+
const {
28+
/**
29+
* @ignore
30+
*/
31+
Provider,
32+
/**
33+
* @ignore
34+
*/
35+
Consumer,
36+
} = context;
2537

2638
export { Provider, Consumer, LDContext };
2739
export default context;

src/initLDClient.ts

+23
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,34 @@ import { initialize as ldClientInitialize, LDClient, LDFlagSet, LDOptions, LDUse
22
import { defaultReactOptions, LDReactOptions } from './types';
33
import { camelCaseKeys } from './utils';
44

5+
/**
6+
* Return type of `initLDClient`.
7+
*/
58
interface AllFlagsLDClient {
9+
/**
10+
* Contains all flags from LaunchDarkly.
11+
*/
612
flags: LDFlagSet;
13+
14+
/**
15+
* An instance of `LDClient` from the LaunchDarkly JS SDK (`launchdarkly-js-client-sdk`).
16+
*
17+
* @see http://docs.launchdarkly.com/docs/js-sdk-reference
18+
*/
719
ldClient: LDClient;
820
}
921

22+
/**
23+
* Internal function to initialize the `LDClient`.
24+
*
25+
* @param clientSideID Your project and environment specific client side ID
26+
* @param user A LaunchDarkly user object
27+
* @param options LaunchDarkly initialization options
28+
* @param targetFlags If specified, `launchdarkly-react-client-sdk` will only request and listen to these flags.
29+
*
30+
* @see `ProviderConfig` for more details about the parameters
31+
* @return An initialized client and flags
32+
*/
1033
const initLDClient = async (
1134
clientSideID: string,
1235
user: LDUser = { anonymous: true },

0 commit comments

Comments
 (0)