Browse Source

working on docs

Daniel Zlotin 6 years ago
parent
commit
3ce3b1e061

+ 1
- 1
docs/README.md View File

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

+ 3
- 2
docs/_sidebar.md View File

1
+- [Home](/)
1
 - Getting Started
2
 - Getting Started
2
   - [Installing](/docs/Installing)
3
   - [Installing](/docs/Installing)
3
   - [Working Locally](/docs/WorkingLocally)
4
   - [Working Locally](/docs/WorkingLocally)
4
   - [Usage](/docs/Usage)
5
   - [Usage](/docs/Usage)
6
+- [API](/api/README)
5
 - Guide
7
 - Guide
6
   - [Top Level](/docs/top-level-api)
8
   - [Top Level](/docs/top-level-api)
7
   - [Screen](/docs/screen-api)
9
   - [Screen](/docs/screen-api)
8
   - [Layout Types](/docs/layout-types)
10
   - [Layout Types](/docs/layout-types)
9
   - [Styling](/docs/styling)
11
   - [Styling](/docs/styling)
10
 - Migration from v1
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 View File

1
 # Navigation
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
 Every navigation component in your app must be registered with a unique name.
15
 Every navigation component in your app must be registered with a unique name.
14
 The component itself is a traditional React component extending React.Component.
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
 Reset the app to a new layout
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
 Set default options to all screens. Useful for declaring a consistent style across the app.
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
 Change a component's navigation options
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
 Show a screen as a modal.
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
 Dismiss a modal by componentId. The dismissed modal can be anywhere in the stack.
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
 Dismiss all Modals
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
 Push a new layout into this screen's navigation stack.
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
 Pop a component from the stack, regardless of it's position.
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
 Pop the stack to a given component
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
 Pop the component's stack to root.
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
 Sets new root component to stack.
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
 Show overlay on top of the entire app
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
 dismiss overlay by componentId
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
 Obtain the events registry instance
156
 Obtain the events registry instance
185
 
157
 
186
-#### Returns
187
-- (`EventsRegistry`)
158
+---
159
+
188
 
160
 

+ 3
- 0
docs/api/_sidebar.md View File

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

+ 2
- 1
docs/index.html View File

15
 
15
 
16
 <body>
16
 <body>
17
   <div id="app">Please wait...</div>
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
   <script>
19
   <script>
20
     window.$docsify = {
20
     window.$docsify = {
21
       name: 'React Native Navigation',
21
       name: 'React Native Navigation',
24
       search: 'auto',
24
       search: 'auto',
25
       loadSidebar: true,
25
       loadSidebar: true,
26
       alias: {
26
       alias: {
27
+        '/api/_sidebar.md': '/api/_sidebar.md',
27
         '/.*/_sidebar.md': '/_sidebar.md'
28
         '/.*/_sidebar.md': '/_sidebar.md'
28
       },
29
       },
29
       subMaxLevel: 2,
30
       subMaxLevel: 2,

+ 7
- 5
scripts/gen-docs/Main.ts View File

3
 import { MarkdownCreator } from './MarkdownCreator';
3
 import { MarkdownCreator } from './MarkdownCreator';
4
 import * as Handlebars from 'handlebars';
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
 const OUTPUT_DIR = `${__dirname}/../../docs/api`;
7
 const OUTPUT_DIR = `${__dirname}/../../docs/api`;
8
+const SOURCE_LINK_PREFIX = `https://github.com/wix/react-native-navigation/blob/v2/lib/src`;
8
 const TEMPLATES_DIR = `${__dirname}/templates`;
9
 const TEMPLATES_DIR = `${__dirname}/templates`;
9
 const TSCONFIG = JSON.parse(fs.readFileSync(`${__dirname}/../../tsconfig.json`).toString());
10
 const TSCONFIG = JSON.parse(fs.readFileSync(`${__dirname}/../../tsconfig.json`).toString());
10
 
11
 
12
   public run() {
13
   public run() {
13
     const handlebarsFn = this.setupHandlebars();
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
     fs.writeFileSync(`${OUTPUT_DIR}/Navigation.md`, markdown, { encoding: 'utf8' });
19
     fs.writeFileSync(`${OUTPUT_DIR}/Navigation.md`, markdown, { encoding: 'utf8' });
19
   }
20
   }
20
 
21
 
21
   private setupHandlebars() {
22
   private setupHandlebars() {
22
-    const mainTemplate = fs.readFileSync(`${TEMPLATES_DIR}/main.hbs`).toString();
23
     const classTemplate = fs.readFileSync(`${TEMPLATES_DIR}/class.hbs`).toString();
23
     const classTemplate = fs.readFileSync(`${TEMPLATES_DIR}/class.hbs`).toString();
24
     const methodTemplate = fs.readFileSync(`${TEMPLATES_DIR}/method.hbs`).toString();
24
     const methodTemplate = fs.readFileSync(`${TEMPLATES_DIR}/method.hbs`).toString();
25
+    const propertyTemplate = fs.readFileSync(`${TEMPLATES_DIR}/property.hbs`).toString();
25
 
26
 
26
     Handlebars.registerPartial('class', classTemplate);
27
     Handlebars.registerPartial('class', classTemplate);
27
     Handlebars.registerPartial('method', methodTemplate);
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 View File

3
 import * as fs from 'fs';
3
 import * as fs from 'fs';
4
 
4
 
5
 export class MarkdownCreator {
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
   public create(reflection: Typedoc.DeclarationReflection) {
8
   public create(reflection: Typedoc.DeclarationReflection) {
9
     const context = {
9
     const context = {
23
       name: methodReflection.name,
23
       name: methodReflection.name,
24
       arguments: this.readArguments(methodReflection.signatures[0].parameters || []),
24
       arguments: this.readArguments(methodReflection.signatures[0].parameters || []),
25
       returnType: methodReflection.signatures[0].type.toString(),
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
       comment: methodReflection.signatures[0].comment ? methodReflection.signatures[0].comment.shortText : ''
27
       comment: methodReflection.signatures[0].comment ? methodReflection.signatures[0].comment.shortText : ''
28
     }));
28
     }));
29
   }
29
   }

+ 3
- 2
scripts/gen-docs/ReflectionsReader.ts View File

1
 import * as Typedoc from 'typedoc';
1
 import * as Typedoc from 'typedoc';
2
+import { OptionsReadMode } from 'typedoc/dist/lib/utils/options';
2
 
3
 
3
 const OPTIONS = {
4
 const OPTIONS = {
4
   excludeExternals: true,
5
   excludeExternals: true,
17
     this.typedocApp = new Typedoc.Application({ ...OPTIONS, ...tsconfig.compilerOptions });
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
     const projectReflection = this.typedocApp.convert(expandedFiles);
23
     const projectReflection = this.typedocApp.convert(expandedFiles);
23
     // console.log(JSON.stringify(this.typedocApp.serializer.projectToObject(projectReflection)));
24
     // console.log(JSON.stringify(this.typedocApp.serializer.projectToObject(projectReflection)));
24
     const externalModule = projectReflection.getChildrenByKind(Typedoc.ReflectionKind.ExternalModule)[0];
25
     const externalModule = projectReflection.getChildrenByKind(Typedoc.ReflectionKind.ExternalModule)[0];

+ 3
- 6
scripts/gen-docs/templates/class.hbs View File

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

+ 0
- 1
scripts/gen-docs/templates/main.hbs View File

1
-{{> class}}

+ 4
- 10
scripts/gen-docs/templates/method.hbs View File

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
 [source]({{source}})
5
 [source]({{source}})
4
 
6
 
6
 {{comment}}
8
 {{comment}}
7
 
9
 
8
 {{/if}}
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 View File

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