Bläddra i källkod

docs ready.. more or less

Daniel Zlotin 6 år sedan
förälder
incheckning
7f515c898e

+ 2
- 2
docs/_sidebar.md Visa fil

@@ -3,11 +3,11 @@
3 3
   - [Installing](/docs/Installing)
4 4
   - [Working Locally](/docs/WorkingLocally)
5 5
   - [Usage](/docs/Usage)
6
-- [API](/api/README)
7 6
 - Guide
8 7
   - [Top Level](/docs/top-level-api)
9 8
   - [Screen](/docs/screen-api)
10 9
   - [Layout Types](/docs/layout-types)
11 10
   - [Styling](/docs/styling)
12 11
 - Migration from v1
13
-  - [Top Level](/docs/top-level-api-migration)
12
+  - [Top Level](/docs/top-level-api-migration)
13
+- [API](/api/README)

+ 107
- 0
docs/api/Commands.md Visa fil

@@ -0,0 +1,107 @@
1
+# Commands
2
+
3
+## setRoot
4
+
5
+`setRoot(simpleApi: any): any`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L12)
8
+
9
+---
10
+
11
+## setDefaultOptions
12
+
13
+`setDefaultOptions(options: any): void`
14
+
15
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L22)
16
+
17
+---
18
+
19
+## mergeOptions
20
+
21
+`mergeOptions(componentId: any, options: any): void`
22
+
23
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L30)
24
+
25
+---
26
+
27
+## showModal
28
+
29
+`showModal(simpleApi: any): any`
30
+
31
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L38)
32
+
33
+---
34
+
35
+## dismissModal
36
+
37
+`dismissModal(componentId: any): any`
38
+
39
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L48)
40
+
41
+---
42
+
43
+## dismissAllModals
44
+
45
+`dismissAllModals(): any`
46
+
47
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L54)
48
+
49
+---
50
+
51
+## push
52
+
53
+`push(componentId: any, simpleApi: any): any`
54
+
55
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L60)
56
+
57
+---
58
+
59
+## pop
60
+
61
+`pop(componentId: any, options: any): any`
62
+
63
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L71)
64
+
65
+---
66
+
67
+## popTo
68
+
69
+`popTo(componentId: any): any`
70
+
71
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L77)
72
+
73
+---
74
+
75
+## popToRoot
76
+
77
+`popToRoot(componentId: any): any`
78
+
79
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L83)
80
+
81
+---
82
+
83
+## setStackRoot
84
+
85
+`setStackRoot(componentId: any, simpleApi: any): any`
86
+
87
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L89)
88
+
89
+---
90
+
91
+## showOverlay
92
+
93
+`showOverlay(simpleApi: any): any`
94
+
95
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L100)
96
+
97
+---
98
+
99
+## dismissOverlay
100
+
101
+`dismissOverlay(componentId: any): any`
102
+
103
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L111)
104
+
105
+---
106
+
107
+

+ 19
- 0
docs/api/CommandsObserver.md Visa fil

@@ -0,0 +1,19 @@
1
+# CommandsObserver
2
+
3
+## register
4
+
5
+`register(listener: CommandsListener): EventSubscription`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/CommandsObserver.ts#L9)
8
+
9
+---
10
+
11
+## notify
12
+
13
+`notify(commandName: string, params: __type): void`
14
+
15
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/CommandsObserver.ts#L17)
16
+
17
+---
18
+
19
+

+ 11
- 0
docs/api/ComponentEventsObserver.md Visa fil

@@ -0,0 +1,11 @@
1
+# ComponentEventsObserver
2
+
3
+## registerForAllComponents
4
+
5
+`registerForAllComponents(): void`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/ComponentEventsObserver.ts#L11)
8
+
9
+---
10
+
11
+

+ 11
- 0
docs/api/ComponentRegistry.md Visa fil

@@ -0,0 +1,11 @@
1
+# ComponentRegistry
2
+
3
+## registerComponent
4
+
5
+`registerComponent(componentName: string, getComponentClassFunc: ComponentProvider): void`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/ComponentRegistry.ts#L11)
8
+
9
+---
10
+
11
+

+ 11
- 0
docs/api/ComponentWrapper.md Visa fil

@@ -0,0 +1,11 @@
1
+# ComponentWrapper
2
+
3
+## wrap
4
+
5
+`wrap(componentName: string, OriginalComponentClass: React.ComponentType<any>, store: any): React.ComponentType<any>`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/ComponentWrapper.tsx#L7)
8
+
9
+---
10
+
11
+

+ 178
- 0
docs/api/Element.md Visa fil

@@ -0,0 +1,178 @@
1
+# Element
2
+
3
+## context
4
+
5
+`context (any)`
6
+
7
+---
8
+## props
9
+
10
+`props (Readonly<object> & Readonly<object>)`
11
+
12
+---
13
+## refs
14
+
15
+`refs (object)`
16
+
17
+---
18
+## state
19
+
20
+`state (Readonly<any>)`
21
+
22
+---
23
+
24
+## render
25
+
26
+`render(): Element`
27
+
28
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/Element.tsx#L17)
29
+
30
+---
31
+
32
+## setState
33
+
34
+`setState(state: function | S | object, callback: function): void`
35
+
36
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L288)
37
+
38
+---
39
+
40
+## forceUpdate
41
+
42
+`forceUpdate(callBack: function): void`
43
+
44
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L293)
45
+
46
+---
47
+
48
+## componentDidMount
49
+
50
+`componentDidMount(): void`
51
+
52
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L377)
53
+
54
+Called immediately after a compoment is mounted. Setting state here will trigger re-rendering.
55
+
56
+---
57
+
58
+## shouldComponentUpdate
59
+
60
+`shouldComponentUpdate(nextProps: Readonly<object>, nextState: Readonly<any>, nextContext: any): boolean`
61
+
62
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L388)
63
+
64
+Called to determine whether the change in props and state should trigger a re-render.
65
+
66
+---
67
+
68
+## componentWillUnmount
69
+
70
+`componentWillUnmount(): void`
71
+
72
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L393)
73
+
74
+Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as
75
+cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`.
76
+
77
+---
78
+
79
+## componentDidCatch
80
+
81
+`componentDidCatch(error: Error, errorInfo: ErrorInfo): void`
82
+
83
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L398)
84
+
85
+Catches exceptions generated in descendant components. Unhandled exceptions will cause
86
+the entire component tree to unmount.
87
+
88
+---
89
+
90
+## getSnapshotBeforeUpdate
91
+
92
+`getSnapshotBeforeUpdate(prevProps: Readonly<object>, prevState: Readonly<any>): SS | null`
93
+
94
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L424)
95
+
96
+Runs before React applies the result of `render` to the document, and
97
+returns an object to be given to componentDidUpdate. Useful for saving
98
+things such as scroll position before `render` causes changes to it.
99
+
100
+---
101
+
102
+## componentDidUpdate
103
+
104
+`componentDidUpdate(prevProps: Readonly<object>, prevState: Readonly<any>, snapshot: SS): void`
105
+
106
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L430)
107
+
108
+Called immediately after updating occurs. Not called for the initial render.
109
+
110
+---
111
+
112
+## componentWillMount
113
+
114
+`componentWillMount(): void`
115
+
116
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L445)
117
+
118
+Called immediately before mounting occurs, and before `Component#render`.
119
+Avoid introducing any side-effects or subscriptions in this method.
120
+
121
+---
122
+
123
+## UNSAFE_componentWillMount
124
+
125
+`UNSAFE_componentWillMount(): void`
126
+
127
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L459)
128
+
129
+Called immediately before mounting occurs, and before `Component#render`.
130
+Avoid introducing any side-effects or subscriptions in this method.
131
+
132
+---
133
+
134
+## componentWillReceiveProps
135
+
136
+`componentWillReceiveProps(nextProps: Readonly<object>, nextContext: any): void`
137
+
138
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L474)
139
+
140
+Called when the component may be receiving new props.
141
+React may call this even if props have not changed, so be sure to compare new and existing
142
+props if you only want to handle changes.
143
+
144
+---
145
+
146
+## UNSAFE_componentWillReceiveProps
147
+
148
+`UNSAFE_componentWillReceiveProps(nextProps: Readonly<object>, nextContext: any): void`
149
+
150
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L491)
151
+
152
+Called when the component may be receiving new props.
153
+React may call this even if props have not changed, so be sure to compare new and existing
154
+props if you only want to handle changes.
155
+
156
+---
157
+
158
+## componentWillUpdate
159
+
160
+`componentWillUpdate(nextProps: Readonly<object>, nextState: Readonly<any>, nextContext: any): void`
161
+
162
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L504)
163
+
164
+Called immediately before rendering when new props or state is received. Not called for the initial render.
165
+
166
+---
167
+
168
+## UNSAFE_componentWillUpdate
169
+
170
+`UNSAFE_componentWillUpdate(nextProps: Readonly<object>, nextState: Readonly<any>, nextContext: any): void`
171
+
172
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src//Users/danielzlotin/dev/react-native-navigation/node_modules/@types/react/index.d.ts#L519)
173
+
174
+Called immediately before rendering when new props or state is received. Not called for the initial render.
175
+
176
+---
177
+
178
+

+ 43
- 0
docs/api/EventsRegistry.md Visa fil

@@ -0,0 +1,43 @@
1
+# EventsRegistry
2
+
3
+## onAppLaunched
4
+
5
+`onAppLaunched(callback: function): EventSubscription`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L11)
8
+
9
+---
10
+
11
+## componentDidAppear
12
+
13
+`componentDidAppear(callback: function): EventSubscription`
14
+
15
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L15)
16
+
17
+---
18
+
19
+## componentDidDisappear
20
+
21
+`componentDidDisappear(callback: function): EventSubscription`
22
+
23
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L19)
24
+
25
+---
26
+
27
+## onNavigationButtonPressed
28
+
29
+`onNavigationButtonPressed(callback: function): EventSubscription`
30
+
31
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L23)
32
+
33
+---
34
+
35
+## onNavigationCommand
36
+
37
+`onNavigationCommand(callback: function): EventSubscription`
38
+
39
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L27)
40
+
41
+---
42
+
43
+

+ 65
- 0
docs/api/LayoutTreeCrawler.md Visa fil

@@ -0,0 +1,65 @@
1
+# LayoutTreeCrawler
2
+
3
+## store
4
+
5
+`store (any)`
6
+
7
+---
8
+
9
+## crawl
10
+
11
+`crawl(node: LayoutNode): void`
12
+
13
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L27)
14
+
15
+---
16
+
17
+## processOptions
18
+
19
+`processOptions(options: any): void`
20
+
21
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L39)
22
+
23
+---
24
+
25
+## _handleComponent
26
+
27
+`_handleComponent(node: any): void`
28
+
29
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L43)
30
+
31
+---
32
+
33
+## _savePropsToStore
34
+
35
+`_savePropsToStore(node: any): void`
36
+
37
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L49)
38
+
39
+---
40
+
41
+## _applyStaticOptions
42
+
43
+`_applyStaticOptions(node: any): void`
44
+
45
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L53)
46
+
47
+---
48
+
49
+## _assertKnownLayoutType
50
+
51
+`_assertKnownLayoutType(type: any): void`
52
+
53
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L60)
54
+
55
+---
56
+
57
+## _assertComponentDataName
58
+
59
+`_assertComponentDataName(component: any): void`
60
+
61
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L66)
62
+
63
+---
64
+
65
+

+ 67
- 0
docs/api/LayoutTreeParser.md Visa fil

@@ -0,0 +1,67 @@
1
+# LayoutTreeParser
2
+
3
+## parse
4
+
5
+`parse(api: any): LayoutNode`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L10)
8
+
9
+---
10
+
11
+## _topTabs
12
+
13
+`_topTabs(api: any): LayoutNode`
14
+
15
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L27)
16
+
17
+---
18
+
19
+## _sideMenu
20
+
21
+`_sideMenu(api: any): LayoutNode`
22
+
23
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L36)
24
+
25
+---
26
+
27
+## _sideMenuChildren
28
+
29
+`_sideMenuChildren(api: any): LayoutNode[]`
30
+
31
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L45)
32
+
33
+---
34
+
35
+## _bottomTabs
36
+
37
+`_bottomTabs(api: any): LayoutNode`
38
+
39
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L75)
40
+
41
+---
42
+
43
+## _stack
44
+
45
+`_stack(api: any): LayoutNode`
46
+
47
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L84)
48
+
49
+---
50
+
51
+## _component
52
+
53
+`_component(api: any): LayoutNode`
54
+
55
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L93)
56
+
57
+---
58
+
59
+## _externalComponent
60
+
61
+`_externalComponent(api: any): LayoutNode`
62
+
63
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L102)
64
+
65
+---
66
+
67
+

+ 107
- 0
docs/api/NativeCommandsSender.md Visa fil

@@ -0,0 +1,107 @@
1
+# NativeCommandsSender
2
+
3
+## setRoot
4
+
5
+`setRoot(layoutTree: object): any`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L9)
8
+
9
+---
10
+
11
+## setDefaultOptions
12
+
13
+`setDefaultOptions(options: object): any`
14
+
15
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L13)
16
+
17
+---
18
+
19
+## mergeOptions
20
+
21
+`mergeOptions(componentId: string, options: object): any`
22
+
23
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L17)
24
+
25
+---
26
+
27
+## push
28
+
29
+`push(onComponentId: string, layout: object): any`
30
+
31
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L21)
32
+
33
+---
34
+
35
+## pop
36
+
37
+`pop(componentId: string, options: object): any`
38
+
39
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L25)
40
+
41
+---
42
+
43
+## popTo
44
+
45
+`popTo(componentId: string): any`
46
+
47
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L29)
48
+
49
+---
50
+
51
+## popToRoot
52
+
53
+`popToRoot(componentId: string): any`
54
+
55
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L33)
56
+
57
+---
58
+
59
+## setStackRoot
60
+
61
+`setStackRoot(onComponentId: string, layout: object): any`
62
+
63
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L37)
64
+
65
+---
66
+
67
+## showModal
68
+
69
+`showModal(layout: object): any`
70
+
71
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L41)
72
+
73
+---
74
+
75
+## dismissModal
76
+
77
+`dismissModal(componentId: string): any`
78
+
79
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L45)
80
+
81
+---
82
+
83
+## dismissAllModals
84
+
85
+`dismissAllModals(): any`
86
+
87
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L49)
88
+
89
+---
90
+
91
+## showOverlay
92
+
93
+`showOverlay(layout: object): any`
94
+
95
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L53)
96
+
97
+---
98
+
99
+## dismissOverlay
100
+
101
+`dismissOverlay(componentId: string): any`
102
+
103
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L57)
104
+
105
+---
106
+
107
+

+ 35
- 0
docs/api/NativeEventsReceiver.md Visa fil

@@ -0,0 +1,35 @@
1
+# NativeEventsReceiver
2
+
3
+## registerOnAppLaunched
4
+
5
+`registerOnAppLaunched(callback: function): EventSubscription`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L10)
8
+
9
+---
10
+
11
+## registerComponentDidAppear
12
+
13
+`registerComponentDidAppear(callback: function): EventSubscription`
14
+
15
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L14)
16
+
17
+---
18
+
19
+## registerComponentDidDisappear
20
+
21
+`registerComponentDidDisappear(callback: function): EventSubscription`
22
+
23
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L18)
24
+
25
+---
26
+
27
+## registerOnNavigationButtonPressed
28
+
29
+`registerOnNavigationButtonPressed(callback: function): EventSubscription`
30
+
31
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L22)
32
+
33
+---
34
+
35
+

+ 22
- 0
docs/api/OptionsProcessor.md Visa fil

@@ -0,0 +1,22 @@
1
+# OptionsProcessor
2
+
3
+## store
4
+
5
+`store (any)`
6
+
7
+---
8
+## uniqueIdProvider
9
+
10
+`uniqueIdProvider (any)`
11
+
12
+---
13
+
14
+## processOptions
15
+
16
+`processOptions(options: any): void`
17
+
18
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/OptionsProcessor.ts#L8)
19
+
20
+---
21
+
22
+

+ 16
- 1
docs/api/README.md Visa fil

@@ -1 +1,16 @@
1
-WIP
1
+- [Home](/)
2
+- [Navigation](/api/Navigation)
3
+- [Element](/api/Element)
4
+- [NativeCommandsSender](/api/NativeCommandsSender)
5
+- [NativeEventsReceiver](/api/NativeEventsReceiver)
6
+- [UniqueIdProvider](/api/UniqueIdProvider)
7
+- [Commands](/api/Commands)
8
+- [LayoutTreeCrawler](/api/LayoutTreeCrawler)
9
+- [LayoutTreeParser](/api/LayoutTreeParser)
10
+- [OptionsProcessor](/api/OptionsProcessor)
11
+- [ComponentRegistry](/api/ComponentRegistry)
12
+- [ComponentWrapper](/api/ComponentWrapper)
13
+- [Store](/api/Store)
14
+- [CommandsObserver](/api/CommandsObserver)
15
+- [ComponentEventsObserver](/api/ComponentEventsObserver)
16
+- [EventsRegistry](/api/EventsRegistry)

+ 59
- 0
docs/api/Store.md Visa fil

@@ -0,0 +1,59 @@
1
+# Store
2
+
3
+## setPropsForId
4
+
5
+`setPropsForId(componentId: string, props: any): void`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L8)
8
+
9
+---
10
+
11
+## getPropsForId
12
+
13
+`getPropsForId(componentId: string): any`
14
+
15
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L12)
16
+
17
+---
18
+
19
+## setOriginalComponentClassForName
20
+
21
+`setOriginalComponentClassForName(componentName: string, ComponentClass: any): void`
22
+
23
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L16)
24
+
25
+---
26
+
27
+## getOriginalComponentClassForName
28
+
29
+`getOriginalComponentClassForName(componentName: string): any`
30
+
31
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L20)
32
+
33
+---
34
+
35
+## setRefForId
36
+
37
+`setRefForId(id: string, ref: any): void`
38
+
39
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L24)
40
+
41
+---
42
+
43
+## getRefForId
44
+
45
+`getRefForId(id: string): any`
46
+
47
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L28)
48
+
49
+---
50
+
51
+## cleanId
52
+
53
+`cleanId(id: string): void`
54
+
55
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L32)
56
+
57
+---
58
+
59
+

+ 11
- 0
docs/api/UniqueIdProvider.md Visa fil

@@ -0,0 +1,11 @@
1
+# UniqueIdProvider
2
+
3
+## generate
4
+
5
+`generate(prefix: string): string`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/UniqueIdProvider.ts#L4)
8
+
9
+---
10
+
11
+

+ 14
- 1
docs/api/_sidebar.md Visa fil

@@ -1,3 +1,16 @@
1 1
 - [Home](/)
2 2
 - [Navigation](/api/Navigation)
3
-- 
3
+- [Element](/api/Element)
4
+- [NativeCommandsSender](/api/NativeCommandsSender)
5
+- [NativeEventsReceiver](/api/NativeEventsReceiver)
6
+- [UniqueIdProvider](/api/UniqueIdProvider)
7
+- [Commands](/api/Commands)
8
+- [LayoutTreeCrawler](/api/LayoutTreeCrawler)
9
+- [LayoutTreeParser](/api/LayoutTreeParser)
10
+- [OptionsProcessor](/api/OptionsProcessor)
11
+- [ComponentRegistry](/api/ComponentRegistry)
12
+- [ComponentWrapper](/api/ComponentWrapper)
13
+- [Store](/api/Store)
14
+- [CommandsObserver](/api/CommandsObserver)
15
+- [ComponentEventsObserver](/api/ComponentEventsObserver)
16
+- [EventsRegistry](/api/EventsRegistry)

+ 1
- 1
package.json Visa fil

@@ -45,7 +45,7 @@
45 45
     "prerelease": "npm run build",
46 46
     "release": "node ./scripts/release",
47 47
     "local-docs": "node ./scripts/local-docs",
48
-    "gen-docs": "echo 'this is a work in progress!!!' && ts-node ./scripts/gen-docs/Main"
48
+    "gen-docs": "ts-node ./scripts/gen-docs/Main"
49 49
   },
50 50
   "peerDependencies": {
51 51
     "react": "*",

scripts/gen-docs/MarkdownCreator.ts → scripts/gen-docs/ClassParser.ts Visa fil

@@ -1,41 +1,63 @@
1 1
 import * as Handlebars from 'handlebars';
2 2
 import * as Typedoc from 'typedoc';
3
-import * as fs from 'fs';
4 3
 
5
-export class MarkdownCreator {
6
-  constructor(private sourceLinkPrefix: string, private handlebarsFn: HandlebarsTemplateDelegate<any>) { }
4
+export interface PropertyContext {
5
+  name: string;
6
+  type: string;
7
+}
8
+
9
+export interface ArgumentContext {
10
+  name: string;
11
+  type: string;
12
+}
13
+
14
+export interface MethodContext {
15
+  name: string;
16
+  arguments: ArgumentContext[];
17
+  returnType: string;
18
+  source: string;
19
+  comment?: string;
20
+}
21
+
22
+export interface ClassContext {
23
+  name: string;
24
+  properties: PropertyContext[];
25
+  methods: MethodContext[];
26
+}
27
+
28
+export class ClassParser {
29
+  constructor(private sourceLinkPrefix: string) { }
7 30
 
8
-  public create(reflection: Typedoc.DeclarationReflection) {
9
-    const context = {
31
+  public parseClass(reflection: Typedoc.DeclarationReflection): ClassContext {
32
+    return {
10 33
       name: reflection.name,
11
-      properties: this.readProperties(reflection),
12
-      methods: this.readMethods(reflection)
34
+      properties: this.parseProperties(reflection),
35
+      methods: this.parseMethods(reflection)
13 36
     };
14
-    return this.handlebarsFn(context);
15 37
   }
16 38
 
17
-  private readMethods(reflection: Typedoc.DeclarationReflection) {
39
+  private parseMethods(reflection: Typedoc.DeclarationReflection): MethodContext[] {
18 40
     const methodReflections = reflection.getChildrenByKind(Typedoc.ReflectionKind.Method);
19 41
 
20 42
     methodReflections.sort((a, b) => a.sources[0].line - b.sources[0].line);
21 43
 
22 44
     return methodReflections.map((methodReflection) => ({
23 45
       name: methodReflection.name,
24
-      arguments: this.readArguments(methodReflection.signatures[0].parameters || []),
46
+      arguments: this.parseArguments(methodReflection.signatures[0].parameters || []),
25 47
       returnType: methodReflection.signatures[0].type.toString(),
26 48
       source: `${this.sourceLinkPrefix}/${methodReflection.sources[0].fileName}#L${methodReflection.sources[0].line}`,
27 49
       comment: methodReflection.signatures[0].comment ? methodReflection.signatures[0].comment.shortText : ''
28 50
     }));
29 51
   }
30 52
 
31
-  private readArguments(parameters: Typedoc.ParameterReflection[]) {
53
+  private parseArguments(parameters: Typedoc.ParameterReflection[]): ArgumentContext[] {
32 54
     return parameters.map((parameter) => ({
33 55
       name: parameter.name,
34 56
       type: parameter.type.toString()
35 57
     }));
36 58
   }
37 59
 
38
-  private readProperties(reflection: Typedoc.DeclarationReflection) {
60
+  private parseProperties(reflection: Typedoc.DeclarationReflection): PropertyContext[] {
39 61
     const propsReflections = reflection.getChildrenByKind(Typedoc.ReflectionKind.Property);
40 62
     return propsReflections.map((propReflection) => ({
41 63
       name: propReflection.name,

+ 17
- 20
scripts/gen-docs/Main.ts Visa fil

@@ -1,34 +1,31 @@
1 1
 import * as fs from 'fs';
2 2
 import { ReflectionsReader } from './ReflectionsReader';
3
-import { MarkdownCreator } from './MarkdownCreator';
4
-import * as Handlebars from 'handlebars';
3
+import { ClassParser } from './ClassParser';
4
+import { MarkdownWriter } from './MarkdownWriter';
5
+import { ReflectionKind } from 'typedoc';
5 6
 
6
-const INPUT_DIR = `${__dirname}/../../lib/src/Navigation.ts`;
7
+const INPUT_DIR = `${__dirname}/../../lib/src`;
7 8
 const OUTPUT_DIR = `${__dirname}/../../docs/api`;
8
-const SOURCE_LINK_PREFIX = `https://github.com/wix/react-native-navigation/blob/v2/lib/src`;
9 9
 const TEMPLATES_DIR = `${__dirname}/templates`;
10
-const TSCONFIG = JSON.parse(fs.readFileSync(`${__dirname}/../../tsconfig.json`).toString());
10
+const TSCONFIG_PATH = `${__dirname}/../../tsconfig.json`;
11
+const SOURCE_LINK_PREFIX = `https://github.com/wix/react-native-navigation/blob/v2/lib/src`;
11 12
 
12 13
 class Main {
13 14
   public run() {
14
-    const handlebarsFn = this.setupHandlebars();
15
-
16
-    const reflection = new ReflectionsReader(TSCONFIG).read(INPUT_DIR);
17
-    const markdown = new MarkdownCreator(SOURCE_LINK_PREFIX, handlebarsFn).create(reflection);
18
-
19
-    fs.writeFileSync(`${OUTPUT_DIR}/Navigation.md`, markdown, { encoding: 'utf8' });
20
-  }
15
+    const classParser = new ClassParser(SOURCE_LINK_PREFIX);
16
+    const markdownWriter = new MarkdownWriter(TEMPLATES_DIR, OUTPUT_DIR);
17
+    const projectReflections = new ReflectionsReader(TSCONFIG_PATH).read(INPUT_DIR);
21 18
 
22
-  private setupHandlebars() {
23
-    const classTemplate = fs.readFileSync(`${TEMPLATES_DIR}/class.hbs`).toString();
24
-    const methodTemplate = fs.readFileSync(`${TEMPLATES_DIR}/method.hbs`).toString();
25
-    const propertyTemplate = fs.readFileSync(`${TEMPLATES_DIR}/property.hbs`).toString();
19
+    const externalModules = projectReflections.getChildrenByKind(ReflectionKind.ExternalModule)
20
+      .filter((m) => !m.name.endsWith('.mock"') && !m.name.endsWith('.test"'));
26 21
 
27
-    Handlebars.registerPartial('class', classTemplate);
28
-    Handlebars.registerPartial('method', methodTemplate);
29
-    Handlebars.registerPartial('property', propertyTemplate);
22
+    const classReflections = externalModules.filter((m) => m.getChildrenByKind(ReflectionKind.Class).length === 1)
23
+      .map((m) => m.getChildrenByKind(ReflectionKind.Class)[0]);
24
+    // just class modules, TODO: extract interfaces and types to their own modules, generate docs for interfaces and types
30 25
 
31
-    return Handlebars.compile('{{> class}}', { strict: true, noEscape: true });
26
+    const parsedClasses = classReflections.map((c) => classParser.parseClass(c));
27
+    markdownWriter.writeClasses(parsedClasses);
28
+    markdownWriter.writeMenu(parsedClasses);
32 29
   }
33 30
 }
34 31
 

+ 44
- 0
scripts/gen-docs/MarkdownWriter.ts Visa fil

@@ -0,0 +1,44 @@
1
+import * as Handlebars from 'handlebars';
2
+import * as fs from 'fs';
3
+import { ClassContext } from './ClassParser';
4
+
5
+export class MarkdownWriter {
6
+  private classFn;
7
+  private menuFn;
8
+  constructor(private templatesDir: string, private outputDir: string) {
9
+    this.classFn = this.setupClassHandlebars();
10
+    this.menuFn = this.setupMenuHandlebars();
11
+  }
12
+
13
+  public writeClasses(classContexts: ClassContext[]) {
14
+    classContexts.forEach((c) => {
15
+      const classMarkdown = this.classFn(c);
16
+      fs.writeFileSync(`${this.outputDir}/${c.name}.md`, classMarkdown, { encoding: 'utf8' });
17
+    });
18
+  }
19
+
20
+  public writeMenu(classContexts: ClassContext[]) {
21
+    const menuMarkdown = this.menuFn({
22
+      classes: classContexts.map((c) => ({ name: c.name, path: `/api/${c.name}` }))
23
+    });
24
+    fs.writeFileSync(`${this.outputDir}/_sidebar.md`, menuMarkdown, { encoding: 'utf8' });
25
+    fs.writeFileSync(`${this.outputDir}/README.md`, menuMarkdown, { encoding: 'utf8' });
26
+  }
27
+
28
+  private setupClassHandlebars() {
29
+    const classTemplate = fs.readFileSync(`${this.templatesDir}/class.hbs`).toString();
30
+    const methodTemplate = fs.readFileSync(`${this.templatesDir}/method.hbs`).toString();
31
+    const propertyTemplate = fs.readFileSync(`${this.templatesDir}/property.hbs`).toString();
32
+
33
+    Handlebars.registerPartial('class', classTemplate);
34
+    Handlebars.registerPartial('method', methodTemplate);
35
+    Handlebars.registerPartial('property', propertyTemplate);
36
+
37
+    return Handlebars.compile('{{> class}}', { strict: true, noEscape: true });
38
+  }
39
+
40
+  private setupMenuHandlebars() {
41
+    const template = fs.readFileSync(`${this.templatesDir}/menu.hbs`).toString();
42
+    return Handlebars.compile(template, { strict: true, noEscape: true });
43
+  }
44
+}

+ 6
- 6
scripts/gen-docs/ReflectionsReader.ts Visa fil

@@ -1,5 +1,6 @@
1 1
 import * as Typedoc from 'typedoc';
2 2
 import { OptionsReadMode } from 'typedoc/dist/lib/utils/options';
3
+import * as fs from 'fs';
3 4
 
4 5
 const OPTIONS = {
5 6
   excludeExternals: true,
@@ -14,16 +15,15 @@ const OPTIONS = {
14 15
 export class ReflectionsReader {
15 16
   private typedocApp: Typedoc.Application;
16 17
 
17
-  constructor(tsconfig) {
18
+  constructor(tsconfigPath) {
19
+    const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath).toString());
18 20
     this.typedocApp = new Typedoc.Application({ ...OPTIONS, ...tsconfig.compilerOptions });
19 21
   }
20 22
 
21
-  public read(modulePathRoot: string): Typedoc.DeclarationReflection {
22
-    const expandedFiles = this.typedocApp.expandInputFiles([modulePathRoot]);
23
+  public read(rootPath: string): Typedoc.ProjectReflection {
24
+    const expandedFiles = this.typedocApp.expandInputFiles([rootPath]);
23 25
     const projectReflection = this.typedocApp.convert(expandedFiles);
24 26
     // console.log(JSON.stringify(this.typedocApp.serializer.projectToObject(projectReflection)));
25
-    const externalModule = projectReflection.getChildrenByKind(Typedoc.ReflectionKind.ExternalModule)[0];
26
-    const classReflection = externalModule.getChildrenByKind(Typedoc.ReflectionKind.Class)[0];
27
-    return classReflection;
27
+    return projectReflection;
28 28
   }
29 29
 }

+ 4
- 0
scripts/gen-docs/templates/menu.hbs Visa fil

@@ -0,0 +1,4 @@
1
+- [Home](/)
2
+{{#each classes}}
3
+- [{{name}}]({{path}})
4
+{{/each}}