Browse Source

[docs] Linkify parameter types (#2403)

Guy Carmeli 6 years ago
parent
commit
2a07ff6e8c
No account linked to committer's email address

+ 1
- 1
docs/docs/BottomTabs.md View File

4
 
4
 
5
 | Name | Type |
5
 | Name | Type |
6
 | --- | --- |
6
 | --- | --- |
7
-| tabs | <code>Array.&lt;Container&gt;</code> | 
7
+| tabs | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/Container">Container[]</a> | 
8
 
8
 

+ 1
- 1
docs/docs/Container.md View File

5
 | Name | Type | Description |
5
 | Name | Type | Description |
6
 | --- | --- | --- |
6
 | --- | --- | --- |
7
 | name | <code>string</code> | The container's registered name |
7
 | name | <code>string</code> | The container's registered name |
8
-| passProps | <code>Object</code> | props |
8
+| passProps | <code>object</code> | props |
9
 
9
 

+ 11
- 11
docs/docs/Navigation.md View File

41
 
41
 
42
 | Param | Type |
42
 | Param | Type |
43
 | --- | --- |
43
 | --- | --- |
44
-| root | <code>Root</code> | 
44
+| root | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/Root">Root</a> | 
45
 
45
 
46
 
46
 
47
 * * *
47
 * * *
54
 
54
 
55
 | Param | Type |
55
 | Param | Type |
56
 | --- | --- |
56
 | --- | --- |
57
-| options | <code>NavigationOptions</code> | 
57
+| options | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/options/NavigationOptions">NavigationOptions</a> | 
58
 
58
 
59
 
59
 
60
 * * *
60
 * * *
68
 | Param | Type | Description |
68
 | Param | Type | Description |
69
 | --- | --- | --- |
69
 | --- | --- | --- |
70
 | containerId | <code>string</code> | The container's id. |
70
 | containerId | <code>string</code> | The container's id. |
71
-| options | <code>NavigationOptions</code> |  |
71
+| options | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/options/NavigationOptions">NavigationOptions</a> |  |
72
 
72
 
73
 
73
 
74
 * * *
74
 * * *
81
 
81
 
82
 | Param | Type |
82
 | Param | Type |
83
 | --- | --- |
83
 | --- | --- |
84
-| params | <code>Object</code> | 
84
+| params | <code>object</code> | 
85
 
85
 
86
 
86
 
87
 * * *
87
 * * *
94
 
94
 
95
 | Param | Type | Description |
95
 | Param | Type | Description |
96
 | --- | --- | --- |
96
 | --- | --- | --- |
97
-| containerId | <code>String</code> | The container's id. |
97
+| containerId | <code>string</code> | The container's id. |
98
 
98
 
99
 
99
 
100
 * * *
100
 * * *
115
 
115
 
116
 | Param | Type | Description |
116
 | Param | Type | Description |
117
 | --- | --- | --- |
117
 | --- | --- | --- |
118
-| containerId | <code>String</code> | The container's id. |
119
-| params | <code>\*</code> |  |
118
+| containerId | <code>string</code> | The container's id. |
119
+| params | <code>*</code> |  |
120
 
120
 
121
 
121
 
122
 * * *
122
 * * *
129
 
129
 
130
 | Param | Type | Description |
130
 | Param | Type | Description |
131
 | --- | --- | --- |
131
 | --- | --- | --- |
132
-| containerId | <code>String</code> | The container's id. |
133
-| params | <code>\*</code> |  |
132
+| containerId | <code>string</code> | The container's id. |
133
+| params | <code>*</code> |  |
134
 
134
 
135
 
135
 
136
 * * *
136
 * * *
143
 
143
 
144
 | Param | Type | Description |
144
 | Param | Type | Description |
145
 | --- | --- | --- |
145
 | --- | --- | --- |
146
-| containerId | <code>String</code> | The container's id. |
146
+| containerId | <code>string</code> | The container's id. |
147
 
147
 
148
 
148
 
149
 * * *
149
 * * *
156
 
156
 
157
 | Param | Type |
157
 | Param | Type |
158
 | --- | --- |
158
 | --- | --- |
159
-| containerId | <code>\*</code> | 
159
+| containerId | <code>*</code> | 
160
 
160
 
161
 
161
 
162
 * * *
162
 * * *

+ 3
- 3
docs/docs/Root.md View File

4
 
4
 
5
 | Name | Type |
5
 | Name | Type |
6
 | --- | --- |
6
 | --- | --- |
7
-| container | <code>Container</code> | 
8
-| sideMenu | <code>SideMenu</code> | 
9
-| bottomTabs | <code>BottomTabs</code> | 
7
+| container | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/Container">Container</a> | 
8
+| sideMenu | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/SideMenu">SideMenu</a> | 
9
+| bottomTabs | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/BottomTabs">BottomTabs</a> | 
10
 
10
 

+ 2
- 2
docs/docs/SideMenu.md View File

4
 
4
 
5
 | Name | Type |
5
 | Name | Type |
6
 | --- | --- |
6
 | --- | --- |
7
-| left | <code>Container</code> | 
8
-| right | <code>Container</code> | 
7
+| left | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/Container">Container</a> | 
8
+| right | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/Container">Container</a> | 
9
 
9
 

+ 1
- 1
docs/docs/options/Button.md View File

4
 
4
 
5
 | Name | Type |
5
 | Name | Type |
6
 | --- | --- |
6
 | --- | --- |
7
-| id | <code>String</code> | 
7
+| id | <code>string</code> | 
8
 | testID | <code>string</code> | 
8
 | testID | <code>string</code> | 
9
 | title | <code>string</code> | 
9
 | title | <code>string</code> | 
10
 | buttonColor | <code>string</code> | 
10
 | buttonColor | <code>string</code> | 

+ 5
- 5
docs/docs/options/NavigationOptions.md View File

4
 
4
 
5
 | Name | Type |
5
 | Name | Type |
6
 | --- | --- |
6
 | --- | --- |
7
-| topBar | <code>TopBar</code> | 
8
-| bottomTabs | <code>BottomTabs</code> | 
9
-| orientation | <code>String</code> | 
10
-| rightButtons | <code>Button</code> | 
11
-| leftButtons | <code>Button</code> | 
7
+| topBar | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/options/TopBar">TopBar</a> | 
8
+| bottomTabs | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/options/BottomTabs">BottomTabs</a> | 
9
+| orientation | <code>string</code> | 
10
+| rightButtons | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/options/Button">Button[]</a> | 
11
+| leftButtons | <a href="https://wix.github.io/react-native-navigation/v2/#/docs/options/Button">Button[]</a> | 
12
 
12
 

+ 9
- 0
docs/linkify.js View File

1
+const URL = 'https://wix.github.io/react-native-navigation/v2/#/docs/';
2
+const isLetter = (c) => c.toLowerCase() !== c.toUpperCase();
3
+const isClass = (type) => isLetter(type[0]) && (type.includes(':') || type[0] === type[0].toUpperCase());
4
+const stripArray = (type) => type.substring(type.indexOf('<') + 1, type.indexOf('>'));
5
+const classUrl = (type) => URL + (type.includes('Array.<') ? stripArray(type) : type).replace(':', '/');
6
+const className = (type) => type.includes('Array.<') ? className(stripArray(type)) + '[]' : type.substring(type.indexOf(':') + 1);
7
+const url = (type) => `<a href="${classUrl(type)}">${className(type)}</a>`;
8
+const simpleString = (type) => `<code>${type}</code>`;
9
+exports.linkify = (type) => isClass(type) ? url(type) : simpleString(type);

+ 1
- 0
docs/stringify.js View File

1
+exports.stringify = (obj) => JSON.stringify(obj);

+ 25
- 0
docs/templates/link.hbs View File

1
+{{! usage: link to="namepath" html=true/false caption="optional caption"~}}
2
+
3
+{{~#if html~}}
4
+<code>
5
+
6
+{{~#link to~}}
7
+{{#if url~}}
8
+<a href="{{{url}}}">{{#if ../../caption}}{{../../../caption}}{{else}}{{name}}{{/if}}</a>
9
+{{~else~}}
10
+{{#if ../../caption}}{{../../../caption}}{{else}}{{name}}{{/if~}}
11
+{{/if~}}
12
+{{/link~}}
13
+
14
+</code>
15
+{{~else~}}
16
+
17
+{{#link to~}}
18
+{{#if url~}}
19
+[<code>{{#if ../../caption}}{{escape ../../../caption}}{{else}}{{escape name}}{{/if}}</code>]({{{url}}})
20
+{{~else~}}
21
+{{#if ../../caption}}<code>{{escape ../../../caption}}</code>{{else}}{{{linkify name}}}{{/if~}}
22
+{{~/if~}}
23
+{{/link~}}
24
+
25
+{{/if~}}

+ 4
- 0
docs/templates/linked-type-list.hbs View File

1
+{{#each types~}}
2
+{{>link to=this html=../html ~}}
3
+{{#unless @last}}{{{../../delimiter}}}{{/unless~}}
4
+{{/each}}

+ 4
- 0
docs/templates/param-table-name.hbs View File

1
+{{#if optional}}[{{/if~}}
2
+{{#if variable}}...{{/if~}}
3
+{{{name}~}}
4
+{{#if optional}}]{{/if}}

+ 12
- 0
docs/templates/params-table.hbs View File

1
+{{#if params}}
2
+
3
+{{tableHead params "name|Param" "type|Type" "defaultvalue|Default" "description|Description" ~}}
4
+
5
+{{#tableRow params "name" "type" "defaultvalue" "description" ~}}
6
+| {{#if @col1}}{{>param-table-name}} | {{/if~}}
7
+{{#if @col2}}{{>linked-type-list types=type.names delimiter=" \| " }} | {{/if~}}
8
+{{#if @col3}}{{>defaultvalue}} | {{/if~}}
9
+{{#if @col4}}{{{stripNewlines (inlineLinks description)}}} |{{/if}}
10
+{{/tableRow}}
11
+
12
+{{/if}}

+ 7
- 7
lib/src/Navigation.js View File

48
 
48
 
49
   /**
49
   /**
50
    * Set default options to all screens. Useful for declaring a consistent style across the app.
50
    * Set default options to all screens. Useful for declaring a consistent style across the app.
51
-   * @param {NavigationOptions} options
51
+   * @param {options:NavigationOptions} options
52
    */
52
    */
53
   setDefaultOptions(options) {
53
   setDefaultOptions(options) {
54
     this.commands.setDefaultOptions(options);
54
     this.commands.setDefaultOptions(options);
57
   /**
57
   /**
58
    * Change a containers navigation options
58
    * Change a containers navigation options
59
    * @param {string} containerId The container's id.
59
    * @param {string} containerId The container's id.
60
-   * @param {NavigationOptions} options
60
+   * @param {options:NavigationOptions} options
61
    */
61
    */
62
   setOptions(containerId, options) {
62
   setOptions(containerId, options) {
63
     this.commands.setOptions(containerId, new NavigationOptions(options));
63
     this.commands.setOptions(containerId, new NavigationOptions(options));
65
 
65
 
66
   /**
66
   /**
67
    * Show a screen as a modal.
67
    * Show a screen as a modal.
68
-   * @param {Object} params
68
+   * @param {object} params
69
    */
69
    */
70
   showModal(params) {
70
   showModal(params) {
71
     return this.commands.showModal(params);
71
     return this.commands.showModal(params);
73
 
73
 
74
   /**
74
   /**
75
    * Dismiss a modal by containerId. The dismissed modal can be anywhere in the stack.
75
    * Dismiss a modal by containerId. The dismissed modal can be anywhere in the stack.
76
-   * @param {String} containerId The container's id.
76
+   * @param {string} containerId The container's id.
77
    */
77
    */
78
   dismissModal(containerId) {
78
   dismissModal(containerId) {
79
     return this.commands.dismissModal(containerId);
79
     return this.commands.dismissModal(containerId);
88
 
88
 
89
   /**
89
   /**
90
    * Push a new screen into this screen's navigation stack.
90
    * Push a new screen into this screen's navigation stack.
91
-   * @param {String} containerId The container's id.
91
+   * @param {string} containerId The container's id.
92
    * @param {*} params
92
    * @param {*} params
93
    */
93
    */
94
   push(containerId, params) {
94
   push(containerId, params) {
97
 
97
 
98
   /**
98
   /**
99
    * Pop a container from the stack, regardless of it's position.
99
    * Pop a container from the stack, regardless of it's position.
100
-   * @param {String} containerId The container's id.
100
+   * @param {string} containerId The container's id.
101
    * @param {*} params
101
    * @param {*} params
102
    */
102
    */
103
   pop(containerId, params) {
103
   pop(containerId, params) {
106
 
106
 
107
   /**
107
   /**
108
    * Pop the stack to a given container
108
    * Pop the stack to a given container
109
-   * @param {String} containerId The container's id.
109
+   * @param {string} containerId The container's id.
110
    */
110
    */
111
   popTo(containerId) {
111
   popTo(containerId) {
112
     return this.commands.popTo(containerId);
112
     return this.commands.popTo(containerId);

+ 1
- 1
lib/src/params/containers/Container.js View File

1
 class Container {
1
 class Container {
2
   /**
2
   /**
3
    * @property {string} name The container's registered name
3
    * @property {string} name The container's registered name
4
-   * @property {Object} [passProps] props
4
+   * @property {object} [passProps] props
5
    */
5
    */
6
   constructor(params) {
6
   constructor(params) {
7
     if (!params || !params.name) {
7
     if (!params || !params.name) {

+ 1
- 1
lib/src/params/options/Button.js View File

1
 class Button {
1
 class Button {
2
   /**
2
   /**
3
-   * @property {String} id
3
+   * @property {string} id
4
    * @property {string} [testID]
4
    * @property {string} [testID]
5
    * @property {string} [title]
5
    * @property {string} [title]
6
    * @property {string} [buttonColor]
6
    * @property {string} [buttonColor]

+ 5
- 5
lib/src/params/options/NavigationOptions.js View File

4
 
4
 
5
 class NavigationOptions {
5
 class NavigationOptions {
6
   /**
6
   /**
7
-   * @property {TopBar} topBar
8
-   * @property {BottomTabs} bottomTabs
9
-   * @property {String} [orientation]
10
-   * @property {Button} [rightButtons]
11
-   * @property {Button} [leftButtons]
7
+   * @property {options:TopBar} [topBar]
8
+   * @property {options:BottomTabs} [bottomTabs]
9
+   * @property {string} [orientation]
10
+   * @property {options:Button[]} [rightButtons]
11
+   * @property {options:Button[]} [leftButtons]
12
    */
12
    */
13
   constructor(options) {
13
   constructor(options) {
14
     this.topBar = options.topBar && new TopBar(options.topBar);
14
     this.topBar = options.topBar && new TopBar(options.topBar);

+ 9
- 1
scripts/generate-js-doc.js View File

7
 const CONTAINERS_DIR = BASE_DIR + 'containers/';
7
 const CONTAINERS_DIR = BASE_DIR + 'containers/';
8
 const OUTPUT_DIR = './docs/docs/';
8
 const OUTPUT_DIR = './docs/docs/';
9
 const PARAMS_PARTIALS = ['./docs/templates/header.hbs', './docs/templates/sig-name.hbs'];
9
 const PARAMS_PARTIALS = ['./docs/templates/header.hbs', './docs/templates/sig-name.hbs'];
10
-const PARTIALS = ['./docs/templates/scope.hbs', './docs/templates/docs.hbs'];
10
+const PARTIALS = [
11
+  './docs/templates/scope.hbs',
12
+  './docs/templates/docs.hbs',
13
+  './docs/templates/param-table-name.hbs',
14
+  '/docs/templates/linked-type-list.hbs',
15
+  './docs/templates/link.hbs',
16
+  './docs/templates/params-table.hbs'
17
+];
11
 
18
 
12
 const generateMarkdownForFile = ({ file, outputDir, partial, separator }) => {
19
 const generateMarkdownForFile = ({ file, outputDir, partial, separator }) => {
13
   const templateData = jsdoc2md.getTemplateDataSync({ files: file });
20
   const templateData = jsdoc2md.getTemplateDataSync({ files: file });
32
     template,
39
     template,
33
     separators: separator,
40
     separators: separator,
34
     'heading-depth': 1,
41
     'heading-depth': 1,
42
+    helper: ['./docs/linkify.js', './docs/stringify.js'],
35
     partial: [...PARTIALS, ...partial]
43
     partial: [...PARTIALS, ...partial]
36
   };
44
   };
37
   console.log(`rendering ${className}`);
45
   console.log(`rendering ${className}`);