Daniel Zlotin преди 6 години
родител
ревизия
3ce3b1e061

+ 1
- 1
docs/README.md Целия файл

@@ -14,7 +14,7 @@ We are rebuilding react-native-navigation.
14 14
 - [v2 Roadmap](#v2-roadmap)
15 15
 - [v1 vs v2 feature comparison](#v1-vs-v2-feature-comparison)
16 16
 - [Documentation](https://wix.github.io/react-native-navigation/v2/)
17
-- [Contributing](/docs/docs/WorkingLocally.md)
17
+- [Contributing](/docs/WorkingLocally.md)
18 18
 
19 19
 ## Why Rebuild react-native-navigation?
20 20
 

+ 3
- 2
docs/_sidebar.md Целия файл

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

+ 66
- 94
docs/api/Navigation.md Целия файл

@@ -1,188 +1,160 @@
1 1
 # Navigation
2 2
 
3
-## Properties
3
+## Element
4 4
 
5
-- Element (`React.ComponentType<object>`)
5
+`Element (React.ComponentType<object>)`
6 6
 
7
-## Methods
7
+---
8 8
 
9
-### `registerComponent(componentName: string, getComponentClassFunc: ComponentProvider): void`
9
+## registerComponent
10 10
 
11
-[source](/lib/src//Navigation.ts#52)
11
+`registerComponent(componentName: string, getComponentClassFunc: ComponentProvider): void`
12
+
13
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L52)
12 14
 
13 15
 Every navigation component in your app must be registered with a unique name.
14 16
 The component itself is a traditional React component extending React.Component.
15 17
 
16
-#### Arguments
17
-- componentName (`string`)
18
-- getComponentClassFunc (`ComponentProvider`)
18
+---
19 19
 
20
-#### Returns
21
-- (`void`)
20
+## setRoot
22 21
 
23
-### `setRoot(layout: any): Promise<any>`
22
+`setRoot(layout: any): Promise<any>`
24 23
 
25
-[source](/lib/src//Navigation.ts#59)
24
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L59)
26 25
 
27 26
 Reset the app to a new layout
28 27
 
29
-#### Arguments
30
-- layout (`any`)
28
+---
31 29
 
32
-#### Returns
33
-- (`Promise<any>`)
30
+## setDefaultOptions
34 31
 
35
-### `setDefaultOptions(options: any): void`
32
+`setDefaultOptions(options: any): void`
36 33
 
37
-[source](/lib/src//Navigation.ts#66)
34
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L66)
38 35
 
39 36
 Set default options to all screens. Useful for declaring a consistent style across the app.
40 37
 
41
-#### Arguments
42
-- options (`any`)
38
+---
43 39
 
44
-#### Returns
45
-- (`void`)
40
+## mergeOptions
46 41
 
47
-### `mergeOptions(componentId: string, options: any): void`
42
+`mergeOptions(componentId: string, options: any): void`
48 43
 
49
-[source](/lib/src//Navigation.ts#73)
44
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L73)
50 45
 
51 46
 Change a component's navigation options
52 47
 
53
-#### Arguments
54
-- componentId (`string`)
55
-- options (`any`)
48
+---
56 49
 
57
-#### Returns
58
-- (`void`)
50
+## showModal
59 51
 
60
-### `showModal(layout: any): Promise<any>`
52
+`showModal(layout: any): Promise<any>`
61 53
 
62
-[source](/lib/src//Navigation.ts#80)
54
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L80)
63 55
 
64 56
 Show a screen as a modal.
65 57
 
66
-#### Arguments
67
-- layout (`any`)
58
+---
68 59
 
69
-#### Returns
70
-- (`Promise<any>`)
60
+## dismissModal
71 61
 
72
-### `dismissModal(componentId: string): Promise<any>`
62
+`dismissModal(componentId: string): Promise<any>`
73 63
 
74
-[source](/lib/src//Navigation.ts#87)
64
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L87)
75 65
 
76 66
 Dismiss a modal by componentId. The dismissed modal can be anywhere in the stack.
77 67
 
78
-#### Arguments
79
-- componentId (`string`)
68
+---
80 69
 
81
-#### Returns
82
-- (`Promise<any>`)
70
+## dismissAllModals
83 71
 
84
-### `dismissAllModals(): Promise<any>`
72
+`dismissAllModals(): Promise<any>`
85 73
 
86
-[source](/lib/src//Navigation.ts#94)
74
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L94)
87 75
 
88 76
 Dismiss all Modals
89 77
 
90
-#### Returns
91
-- (`Promise<any>`)
78
+---
79
+
80
+## push
92 81
 
93
-### `push(componentId: string, layout: any): Promise<any>`
82
+`push(componentId: string, layout: any): Promise<any>`
94 83
 
95
-[source](/lib/src//Navigation.ts#101)
84
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L101)
96 85
 
97 86
 Push a new layout into this screen's navigation stack.
98 87
 
99
-#### Arguments
100
-- componentId (`string`)
101
-- layout (`any`)
88
+---
102 89
 
103
-#### Returns
104
-- (`Promise<any>`)
90
+## pop
105 91
 
106
-### `pop(componentId: string, params: any): Promise<any>`
92
+`pop(componentId: string, params: any): Promise<any>`
107 93
 
108
-[source](/lib/src//Navigation.ts#108)
94
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L108)
109 95
 
110 96
 Pop a component from the stack, regardless of it's position.
111 97
 
112
-#### Arguments
113
-- componentId (`string`)
114
-- params (`any`)
98
+---
115 99
 
116
-#### Returns
117
-- (`Promise<any>`)
100
+## popTo
118 101
 
119
-### `popTo(componentId: string): Promise<any>`
102
+`popTo(componentId: string): Promise<any>`
120 103
 
121
-[source](/lib/src//Navigation.ts#115)
104
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L115)
122 105
 
123 106
 Pop the stack to a given component
124 107
 
125
-#### Arguments
126
-- componentId (`string`)
108
+---
127 109
 
128
-#### Returns
129
-- (`Promise<any>`)
110
+## popToRoot
130 111
 
131
-### `popToRoot(componentId: string): Promise<any>`
112
+`popToRoot(componentId: string): Promise<any>`
132 113
 
133
-[source](/lib/src//Navigation.ts#122)
114
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L122)
134 115
 
135 116
 Pop the component's stack to root.
136 117
 
137
-#### Arguments
138
-- componentId (`string`)
118
+---
139 119
 
140
-#### Returns
141
-- (`Promise<any>`)
120
+## setStackRoot
142 121
 
143
-### `setStackRoot(componentId: string, layout: any): Promise<any>`
122
+`setStackRoot(componentId: string, layout: any): Promise<any>`
144 123
 
145
-[source](/lib/src//Navigation.ts#129)
124
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L129)
146 125
 
147 126
 Sets new root component to stack.
148 127
 
149
-#### Arguments
150
-- componentId (`string`)
151
-- layout (`any`)
128
+---
152 129
 
153
-#### Returns
154
-- (`Promise<any>`)
130
+## showOverlay
155 131
 
156
-### `showOverlay(layout: any): Promise<any>`
132
+`showOverlay(layout: any): Promise<any>`
157 133
 
158
-[source](/lib/src//Navigation.ts#136)
134
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L136)
159 135
 
160 136
 Show overlay on top of the entire app
161 137
 
162
-#### Arguments
163
-- layout (`any`)
138
+---
164 139
 
165
-#### Returns
166
-- (`Promise<any>`)
140
+## dismissOverlay
167 141
 
168
-### `dismissOverlay(componentId: string): Promise<any>`
142
+`dismissOverlay(componentId: string): Promise<any>`
169 143
 
170
-[source](/lib/src//Navigation.ts#143)
144
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L143)
171 145
 
172 146
 dismiss overlay by componentId
173 147
 
174
-#### Arguments
175
-- componentId (`string`)
148
+---
176 149
 
177
-#### Returns
178
-- (`Promise<any>`)
150
+## events
179 151
 
180
-### `events(): EventsRegistry`
152
+`events(): EventsRegistry`
181 153
 
182
-[source](/lib/src//Navigation.ts#150)
154
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L150)
183 155
 
184 156
 Obtain the events registry instance
185 157
 
186
-#### Returns
187
-- (`EventsRegistry`)
158
+---
159
+
188 160
 

+ 3
- 0
docs/api/_sidebar.md Целия файл

@@ -0,0 +1,3 @@
1
+- [Home](/)
2
+- [Navigation](/api/Navigation)
3
+- 

+ 2
- 1
docs/index.html Целия файл

@@ -15,7 +15,7 @@
15 15
 
16 16
 <body>
17 17
   <div id="app">Please wait...</div>
18
-  <script src="//unpkg.com/docsify-copy-code/index.js"></script>
18
+  <script src="//unpkg.com/docsify-copy-code"></script>
19 19
   <script>
20 20
     window.$docsify = {
21 21
       name: 'React Native Navigation',
@@ -24,6 +24,7 @@
24 24
       search: 'auto',
25 25
       loadSidebar: true,
26 26
       alias: {
27
+        '/api/_sidebar.md': '/api/_sidebar.md',
27 28
         '/.*/_sidebar.md': '/_sidebar.md'
28 29
       },
29 30
       subMaxLevel: 2,

+ 7
- 5
scripts/gen-docs/Main.ts Целия файл

@@ -3,8 +3,9 @@ import { ReflectionsReader } from './ReflectionsReader';
3 3
 import { MarkdownCreator } from './MarkdownCreator';
4 4
 import * as Handlebars from 'handlebars';
5 5
 
6
-const MD_RELATIVE_LINK = `/lib/src/`;
6
+const INPUT_DIR = `${__dirname}/../../lib/src/Navigation.ts`;
7 7
 const OUTPUT_DIR = `${__dirname}/../../docs/api`;
8
+const SOURCE_LINK_PREFIX = `https://github.com/wix/react-native-navigation/blob/v2/lib/src`;
8 9
 const TEMPLATES_DIR = `${__dirname}/templates`;
9 10
 const TSCONFIG = JSON.parse(fs.readFileSync(`${__dirname}/../../tsconfig.json`).toString());
10 11
 
@@ -12,21 +13,22 @@ class Main {
12 13
   public run() {
13 14
     const handlebarsFn = this.setupHandlebars();
14 15
 
15
-    const reflection = new ReflectionsReader(TSCONFIG).read('./lib/src/Navigation.ts');
16
-    const markdown = new MarkdownCreator(MD_RELATIVE_LINK, handlebarsFn).create(reflection);
16
+    const reflection = new ReflectionsReader(TSCONFIG).read(INPUT_DIR);
17
+    const markdown = new MarkdownCreator(SOURCE_LINK_PREFIX, handlebarsFn).create(reflection);
17 18
 
18 19
     fs.writeFileSync(`${OUTPUT_DIR}/Navigation.md`, markdown, { encoding: 'utf8' });
19 20
   }
20 21
 
21 22
   private setupHandlebars() {
22
-    const mainTemplate = fs.readFileSync(`${TEMPLATES_DIR}/main.hbs`).toString();
23 23
     const classTemplate = fs.readFileSync(`${TEMPLATES_DIR}/class.hbs`).toString();
24 24
     const methodTemplate = fs.readFileSync(`${TEMPLATES_DIR}/method.hbs`).toString();
25
+    const propertyTemplate = fs.readFileSync(`${TEMPLATES_DIR}/property.hbs`).toString();
25 26
 
26 27
     Handlebars.registerPartial('class', classTemplate);
27 28
     Handlebars.registerPartial('method', methodTemplate);
29
+    Handlebars.registerPartial('property', propertyTemplate);
28 30
 
29
-    return Handlebars.compile(mainTemplate, { strict: true, noEscape: true });
31
+    return Handlebars.compile('{{> class}}', { strict: true, noEscape: true });
30 32
   }
31 33
 }
32 34
 

+ 2
- 2
scripts/gen-docs/MarkdownCreator.ts Целия файл

@@ -3,7 +3,7 @@ import * as Typedoc from 'typedoc';
3 3
 import * as fs from 'fs';
4 4
 
5 5
 export class MarkdownCreator {
6
-  constructor(private mdRelativeLinkPath: string, private handlebarsFn: HandlebarsTemplateDelegate<any>) { }
6
+  constructor(private sourceLinkPrefix: string, private handlebarsFn: HandlebarsTemplateDelegate<any>) { }
7 7
 
8 8
   public create(reflection: Typedoc.DeclarationReflection) {
9 9
     const context = {
@@ -23,7 +23,7 @@ export class MarkdownCreator {
23 23
       name: methodReflection.name,
24 24
       arguments: this.readArguments(methodReflection.signatures[0].parameters || []),
25 25
       returnType: methodReflection.signatures[0].type.toString(),
26
-      source: `${this.mdRelativeLinkPath}/${methodReflection.sources[0].fileName}#${methodReflection.sources[0].line}`,
26
+      source: `${this.sourceLinkPrefix}/${methodReflection.sources[0].fileName}#L${methodReflection.sources[0].line}`,
27 27
       comment: methodReflection.signatures[0].comment ? methodReflection.signatures[0].comment.shortText : ''
28 28
     }));
29 29
   }

+ 3
- 2
scripts/gen-docs/ReflectionsReader.ts Целия файл

@@ -1,4 +1,5 @@
1 1
 import * as Typedoc from 'typedoc';
2
+import { OptionsReadMode } from 'typedoc/dist/lib/utils/options';
2 3
 
3 4
 const OPTIONS = {
4 5
   excludeExternals: true,
@@ -17,8 +18,8 @@ export class ReflectionsReader {
17 18
     this.typedocApp = new Typedoc.Application({ ...OPTIONS, ...tsconfig.compilerOptions });
18 19
   }
19 20
 
20
-  public read(modulePath: string): Typedoc.DeclarationReflection {
21
-    const expandedFiles = this.typedocApp.expandInputFiles([modulePath]);
21
+  public read(modulePathRoot: string): Typedoc.DeclarationReflection {
22
+    const expandedFiles = this.typedocApp.expandInputFiles([modulePathRoot]);
22 23
     const projectReflection = this.typedocApp.convert(expandedFiles);
23 24
     // console.log(JSON.stringify(this.typedocApp.serializer.projectToObject(projectReflection)));
24 25
     const externalModule = projectReflection.getChildrenByKind(Typedoc.ReflectionKind.ExternalModule)[0];

+ 3
- 6
scripts/gen-docs/templates/class.hbs Целия файл

@@ -1,17 +1,14 @@
1 1
 # {{name}}
2 2
 
3 3
 {{#if properties}}
4
-## Properties
5
-
6 4
 {{#each properties}}
7
-- {{name}} (`{{type}}`)
5
+{{> property}}
8 6
 {{/each}}
9 7
 
10 8
 {{/if}}
11 9
 {{#if methods}}
12
-## Methods
13
-
14 10
 {{#each methods}}
15 11
 {{> method}}
16 12
 {{/each}}
17
-{{/if}}
13
+
14
+{{/if}}

+ 0
- 1
scripts/gen-docs/templates/main.hbs Целия файл

@@ -1 +0,0 @@
1
-{{> class}}

+ 4
- 10
scripts/gen-docs/templates/method.hbs Целия файл

@@ -1,4 +1,6 @@
1
-### `{{name}}({{#each arguments}}{{name}}: {{type}}{{#unless @last}}, {{/unless}}{{/each}}): {{returnType}}`
1
+## {{name}}
2
+
3
+`{{name}}({{#each arguments}}{{name}}: {{type}}{{#unless @last}}, {{/unless}}{{/each}}): {{returnType}}`
2 4
 
3 5
 [source]({{source}})
4 6
 
@@ -6,13 +8,5 @@
6 8
 {{comment}}
7 9
 
8 10
 {{/if}}
9
-{{#if arguments}}
10
-#### Arguments
11
-{{#each arguments}}
12
-- {{name}} (`{{type}}`)
13
-{{/each}}
14
-
15
-{{/if}}
16
-#### Returns
17
-- (`{{returnType}}`)
11
+---
18 12
 

+ 5
- 0
scripts/gen-docs/templates/property.hbs Целия файл

@@ -0,0 +1,5 @@
1
+## {{name}}
2
+
3
+`{{name}} ({{type}})`
4
+
5
+---