Przeglądaj źródła

Docs3 (#2389)

* Rename TabBar options to BottomTabs

* Restructure docs
Guy Carmeli 6 lat temu
rodzic
commit
c50b06f088
No account linked to committer's email address

+ 5
- 0
docs/_sidebar.md Wyświetl plik

@@ -9,3 +9,8 @@
9 9
  - [Container](/docs/Container)
10 10
  - [TopBar](/docs/TopBar)
11 11
  - [BottomTabs](/docs/BottomTabs)
12
+- Options
13
+ - [BottomTabs](/docs/options/NavigatorOptions)
14
+ - [BottomTabs](/docs/options/BottomTabs)
15
+ - [Button](/docs/options/Button)
16
+ - [BottomTabs](/docs/options/TopBar)

+ 0
- 24
docs/docs/NavigationOptions.md Wyświetl plik

@@ -1,24 +0,0 @@
1
-<a name="exp_module_NavigationOptions--NavigationOptions"></a>
2
-
3
-## NavigationOptions ⏏
4
-NavigationOptions are used by containers to customize their behavior and style.
5
-
6
-
7
-* * *
8
-
9
-<a name="module_NavigationOptions--NavigationOptions..NavigationOptions"></a>
10
-
11
-### NavigationOptions~NavigationOptions : <code>Object</code>
12
-**Properties**
13
-
14
-| Name | Type |
15
-| --- | --- |
16
-| topBar | <code>TopBar</code> | 
17
-| bottomTabs | <code>TabBar</code> | 
18
-| orientation | <code>String</code> | 
19
-| rightButtons | <code>Button</code> | 
20
-| leftButtons | <code>Button</code> | 
21
-
22
-
23
-* * *
24
-

docs/docs/TabBar.md → docs/docs/options/BottomTabs.md Wyświetl plik

@@ -1,6 +1,6 @@
1
-<a name="TabBar"></a>
1
+<a name="BottomTabs"></a>
2 2
 
3
-## TabBar
3
+## BottomTabs
4 4
 **Properties**
5 5
 
6 6
 | Name | Type |

+ 19
- 0
docs/docs/options/Button.md Wyświetl plik

@@ -0,0 +1,19 @@
1
+<a name="Button"></a>
2
+
3
+## Button
4
+**Properties**
5
+
6
+| Name | Type |
7
+| --- | --- |
8
+| id | <code>String</code> | 
9
+| testID | <code>string</code> | 
10
+| title | <code>string</code> | 
11
+| buttonColor | <code>string</code> | 
12
+| showAsAction | <code>string</code> | 
13
+| buttonFontWeight | <code>int</code> | 
14
+| disableIconTint | <code>boolean</code> | 
15
+| disabled | <code>boolean</code> | 
16
+
17
+
18
+* * *
19
+

+ 16
- 0
docs/docs/options/NavigationOptions.md Wyświetl plik

@@ -0,0 +1,16 @@
1
+<a name="NavigationOptions"></a>
2
+
3
+## NavigationOptions
4
+**Properties**
5
+
6
+| Name | Type |
7
+| --- | --- |
8
+| topBar | <code>TopBar</code> | 
9
+| bottomTabs | <code>BottomTabs</code> | 
10
+| orientation | <code>String</code> | 
11
+| rightButtons | <code>Button</code> | 
12
+| leftButtons | <code>Button</code> | 
13
+
14
+
15
+* * *
16
+

+ 20
- 0
docs/docs/options/TopBar.md Wyświetl plik

@@ -0,0 +1,20 @@
1
+<a name="TopBar"></a>
2
+
3
+## TopBar
4
+**Properties**
5
+
6
+| Name | Type |
7
+| --- | --- |
8
+| title | <code>string</code> | 
9
+| backgroundColor | <code>color</code> | 
10
+| textColor | <code>color</code> | 
11
+| textFontSize | <code>number</code> | 
12
+| textFontFamily | <code>string</code> | 
13
+| hidden | <code>boolean</code> | 
14
+| animateHide | <code>boolean</code> | 
15
+| hideOnScroll | <code>boolean</code> | 
16
+| transparent | <code>boolean</code> | 
17
+
18
+
19
+* * *
20
+

+ 1
- 1
lib/src/commands/OptionsProcessor.test.js Wyświetl plik

@@ -1,5 +1,5 @@
1 1
 const OptionsProcessor = require('./OptionsProcessor');
2
-const NavigationOptions = require('./../params/NavigationOptions');
2
+const NavigationOptions = require('./../params/options/NavigationOptions');
3 3
 
4 4
 describe('navigation options', () => {
5 5
   let navigationOptions;

lib/src/params/TabBar.js → lib/src/params/options/BottomTabs.js Wyświetl plik

@@ -1,6 +1,6 @@
1 1
 const { isEmpty } = require('lodash');
2 2
 
3
-class TabBar {
3
+class BottomTabs {
4 4
   /**
5 5
    * @property {string} [currentTabId]
6 6
    * @property {number} [currentTabIndex]
@@ -20,4 +20,4 @@ class TabBar {
20 20
   }
21 21
 }
22 22
 
23
-module.exports = TabBar;
23
+module.exports = BottomTabs;

lib/src/params/TabBar.test.js → lib/src/params/options/BottomTabs.test.js Wyświetl plik

@@ -1,6 +1,6 @@
1
-const TabBar = require('./TabBar');
1
+const BottomTabs = require('./BottomTabs');
2 2
 
3
-const TAB_BAR = {
3
+const BOTTOM_TABS = {
4 4
   currentTabId: 1,
5 5
   currentTabIndex: 2,
6 6
   tabBadge: 3,
@@ -8,9 +8,9 @@ const TAB_BAR = {
8 8
   animateHide: true
9 9
 };
10 10
 
11
-describe('TabBar', () => {
12
-  it('parses TabBar options', () => {
13
-    const uut = new TabBar(TAB_BAR);
11
+describe('BottomTabs', () => {
12
+  it('parses BottomTabs options', () => {
13
+    const uut = new BottomTabs(BOTTOM_TABS);
14 14
     expect(uut.currentTabId).toEqual(1);
15 15
     expect(uut.currentTabIndex).toEqual(2);
16 16
     expect(uut.tabBadge).toEqual(3);

lib/src/params/Button.js → lib/src/params/options/Button.js Wyświetl plik


lib/src/params/Button.test.js → lib/src/params/options/Button.test.js Wyświetl plik


lib/src/params/NavigationOptions.js → lib/src/params/options/NavigationOptions.js Wyświetl plik

@@ -1,28 +1,18 @@
1 1
 const TopBar = require('./TopBar');
2
-const TabBar = require('./TabBar');
2
+const BottomTabs = require('./BottomTabs');
3 3
 const Button = require('./Button');
4 4
 
5
- /**
6
- * A module for adding two values.
7
- * @module NavigationOptions
8
- */
9
-
10
- /**
11
-  * NavigationOptions are used by containers to customize their behavior and style.
12
-  * @alias module:NavigationOptions
13
-  */
14 5
 class NavigationOptions {
15 6
   /**
16
-   * @typedef {Object} NavigationOptions
17 7
    * @property {TopBar} topBar
18
-   * @property {TabBar} bottomTabs
8
+   * @property {BottomTabs} bottomTabs
19 9
    * @property {String} [orientation]
20 10
    * @property {Button} [rightButtons]
21 11
    * @property {Button} [leftButtons]
22 12
    */
23 13
   constructor(options) {
24 14
     this.topBar = options.topBar && new TopBar(options.topBar);
25
-    this.bottomTabs = options.bottomTabs && new TabBar(options.bottomTabs);
15
+    this.bottomTabs = options.bottomTabs && new BottomTabs(options.bottomTabs);
26 16
     this.orientation = options.orientation;
27 17
     this.rightButtons = options.rightButtons && options.rightButtons.map((button) => new Button(button));
28 18
     this.leftButtons = options.leftButtons && options.leftButtons.map((button) => new Button(button));

lib/src/params/NavigationOptions.test.js → lib/src/params/options/NavigationOptions.test.js Wyświetl plik

@@ -1,5 +1,5 @@
1 1
 const NavigationOptions = require('./NavigationOptions');
2
-const TabBar = require('./TabBar');
2
+const BottomTabs = require('./BottomTabs');
3 3
 const TopBar = require('./TopBar');
4 4
 
5 5
 const TAB_BAR = {};
@@ -31,7 +31,7 @@ const NAVIGATION_OPTIONS = {
31 31
 describe('NavigationOptions', () => {
32 32
   it('parses navigationOptions correctly', () => {
33 33
     const uut = new NavigationOptions(NAVIGATION_OPTIONS);
34
-    expect(uut.bottomTabs).toBeInstanceOf(TabBar);
34
+    expect(uut.bottomTabs).toBeInstanceOf(BottomTabs);
35 35
     expect(uut.topBar).toBeInstanceOf(TopBar);
36 36
     expect(uut.orientation).toEqual('portrait');
37 37
     expect(uut.rightButtons).toEqual(RIGHT_BUTTONS);

lib/src/params/TopBar.js → lib/src/params/options/TopBar.js Wyświetl plik


lib/src/params/TopBar.test.js → lib/src/params/options/TopBar.test.js Wyświetl plik


+ 21
- 7
scripts/generate-js-doc.js Wyświetl plik

@@ -3,13 +3,14 @@ const fs = require('fs');
3 3
 const path = require('path');
4 4
 
5 5
 const paramsDir = './lib/src/params/';
6
-const outputDir = './docs/docs/';
6
+const optionsDir = './lib/src/params/options/';
7
+const OUTPUT_DIR = './docs/docs/';
7 8
 const partial = ['./docs/templates/scope.hbs', './docs/templates/docs.hbs'];
8 9
 
9
-const generateMarkdownForFile = (file) => {
10
+const generateMarkdownForFile = ({ file, outputDir }) => {
10 11
   const templateData = jsdoc2md.getTemplateDataSync({ files: file });
11 12
   const classNames = getClassesInFile(templateData);
12
-  classNames.forEach((className) => createDocFileForClass(className, templateData));
13
+  classNames.forEach((className) => createDocFileForClass(className, templateData, outputDir));
13 14
 };
14 15
 
15 16
 function getClassesInFile(templateData) {
@@ -22,7 +23,7 @@ function getClassesInFile(templateData) {
22 23
   return classNames;
23 24
 }
24 25
 
25
-function createDocFileForClass(className, templateData) {
26
+function createDocFileForClass(className, templateData, outputDir) {
26 27
   const template = `{{#class name="${className}"}}{{>docs}}{{/class}}`;
27 28
   const options = {
28 29
     data: templateData,
@@ -30,15 +31,28 @@ function createDocFileForClass(className, templateData) {
30 31
     separators: true,
31 32
     partial
32 33
   };
33
-  console.log(`rendering ${className}, template: ${template}`);
34
+  console.log(`rendering ${className}, template: ${template} ${outputDir}`);
34 35
   const output = jsdoc2md.renderSync(options);
35 36
   fs.writeFileSync(path.resolve(outputDir, `${className}.md`), output);
36 37
 }
37 38
 
38 39
 function inputFiles() {
39 40
   return [
40
-    './lib/src/Navigation.js',
41
-    ...fs.readdirSync(paramsDir).map((file) => paramsDir + file)
41
+    { file: './lib/src/Navigation.js', outputDir: OUTPUT_DIR },
42
+    ...fs.readdirSync(optionsDir).map((file) => {
43
+      return {
44
+        file: optionsDir + file,
45
+        outputDir: OUTPUT_DIR + 'options/'
46
+      };
47
+    }),
48
+    ...fs.readdirSync(paramsDir)
49
+        .filter((file) => fs.statSync(paramsDir + file).isFile())
50
+        .map((file) => {
51
+          return {
52
+            file: paramsDir + file,
53
+            outputDir: OUTPUT_DIR
54
+          };
55
+        })
42 56
   ];
43 57
 }
44 58