Browse Source

support interface docs

Daniel Zlotin 6 years ago
parent
commit
fdcb7aad15

+ 11
- 0
docs/api/EventSubscription.md View File

1
+# EventSubscription
2
+
3
+## remove
4
+
5
+`remove(): any`
6
+
7
+[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/interfaces/EventSubscription.ts#L2)
8
+
9
+---
10
+
11
+

+ 5
- 5
docs/api/EventsRegistry.md View File

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

+ 1
- 0
docs/api/README.md View File

14
 - [CommandsObserver](/api/CommandsObserver)
14
 - [CommandsObserver](/api/CommandsObserver)
15
 - [ComponentEventsObserver](/api/ComponentEventsObserver)
15
 - [ComponentEventsObserver](/api/ComponentEventsObserver)
16
 - [EventsRegistry](/api/EventsRegistry)
16
 - [EventsRegistry](/api/EventsRegistry)
17
+- [EventSubscription](/api/EventSubscription)
17
 - [LayoutType](/api/LayoutType)
18
 - [LayoutType](/api/LayoutType)

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

14
 - [CommandsObserver](/api/CommandsObserver)
14
 - [CommandsObserver](/api/CommandsObserver)
15
 - [ComponentEventsObserver](/api/ComponentEventsObserver)
15
 - [ComponentEventsObserver](/api/ComponentEventsObserver)
16
 - [EventsRegistry](/api/EventsRegistry)
16
 - [EventsRegistry](/api/EventsRegistry)
17
+- [EventSubscription](/api/EventSubscription)
17
 - [LayoutType](/api/LayoutType)
18
 - [LayoutType](/api/LayoutType)

+ 1
- 1
lib/src/adapters/NativeEventsReceiver.ts View File

1
 import { NativeModules, NativeEventEmitter } from 'react-native';
1
 import { NativeModules, NativeEventEmitter } from 'react-native';
2
-import { EventSubscription } from '../events/EventsRegistry';
2
+import { EventSubscription } from '../interfaces/EventSubscription';
3
 
3
 
4
 export class NativeEventsReceiver {
4
 export class NativeEventsReceiver {
5
   private emitter: NativeEventEmitter;
5
   private emitter: NativeEventEmitter;

+ 1
- 1
lib/src/events/CommandsObserver.ts View File

1
 import * as _ from 'lodash';
1
 import * as _ from 'lodash';
2
-import { EventSubscription } from './EventsRegistry';
2
+import { EventSubscription } from '../interfaces/EventSubscription';
3
 
3
 
4
 export type CommandsListener = (name: string, params: {}) => void;
4
 export type CommandsListener = (name: string, params: {}) => void;
5
 
5
 

+ 1
- 4
lib/src/events/EventsRegistry.ts View File

1
 import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver';
1
 import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver';
2
 import { CommandsObserver } from './CommandsObserver';
2
 import { CommandsObserver } from './CommandsObserver';
3
-
4
-export interface EventSubscription {
5
-  remove();
6
-}
3
+import { EventSubscription } from '../interfaces/EventSubscription';
7
 
4
 
8
 export class EventsRegistry {
5
 export class EventsRegistry {
9
   constructor(private nativeEventsReceiver: NativeEventsReceiver, private commandsObserver: CommandsObserver) { }
6
   constructor(private nativeEventsReceiver: NativeEventsReceiver, private commandsObserver: CommandsObserver) { }

+ 3
- 0
lib/src/interfaces/EventSubscription.ts View File

1
+export interface EventSubscription {
2
+  remove();
3
+}

+ 2
- 1
package.json View File

101
       "integration/**/*.js",
101
       "integration/**/*.js",
102
       "!lib/dist/index.js",
102
       "!lib/dist/index.js",
103
       "!lib/dist/Navigation.js",
103
       "!lib/dist/Navigation.js",
104
-      "!lib/dist/adapters/**/*"
104
+      "!lib/dist/adapters/**/*",
105
+      "!lib/dist/interfaces/**/*"
105
     ],
106
     ],
106
     "resetMocks": true,
107
     "resetMocks": true,
107
     "resetModules": true,
108
     "resetModules": true,

+ 6
- 2
scripts/gen-docs/Main.ts View File

14
 class Main {
14
 class Main {
15
   public run() {
15
   public run() {
16
     const classParser = new ClassParser(SOURCE_LINK_PREFIX);
16
     const classParser = new ClassParser(SOURCE_LINK_PREFIX);
17
+    const enumParser = new EnumParser();
17
     const markdownWriter = new MarkdownWriter(TEMPLATES_DIR, OUTPUT_DIR);
18
     const markdownWriter = new MarkdownWriter(TEMPLATES_DIR, OUTPUT_DIR);
18
     const reflections = new ReflectionsReader(TSCONFIG_PATH).read(INPUT_DIR);
19
     const reflections = new ReflectionsReader(TSCONFIG_PATH).read(INPUT_DIR);
19
 
20
 
20
     const parsedClasses = classParser.parseClasses(reflections.classReflections);
21
     const parsedClasses = classParser.parseClasses(reflections.classReflections);
21
-    const parsedEnums = new EnumParser().parse(reflections.enumReflections);
22
+    const parsedInterfaces = classParser.parseClasses(reflections.interfaceReflections);
23
+    const parsedEnums = enumParser.parse(reflections.enumReflections);
24
+
22
     markdownWriter.writeClasses(parsedClasses);
25
     markdownWriter.writeClasses(parsedClasses);
26
+    markdownWriter.writeClasses(parsedInterfaces);
23
     markdownWriter.writeEnums(parsedEnums);
27
     markdownWriter.writeEnums(parsedEnums);
24
-    markdownWriter.writeMenu(parsedClasses, parsedEnums);
28
+    markdownWriter.writeMenu(parsedClasses, parsedInterfaces, parsedEnums);
25
   }
29
   }
26
 }
30
 }
27
 
31
 

+ 7
- 4
scripts/gen-docs/MarkdownWriter.ts View File

28
     });
28
     });
29
   }
29
   }
30
 
30
 
31
-  public writeMenu(classContexts: ClassContext[], enumContexts: EnumContext[]) {
32
-    const files = classContexts.map((c) => ({ name: c.name, path: `/api/${c.name}` }));
33
-    const files2 = enumContexts.map((c) => ({ name: c.name, path: `/api/${c.name}` }));
34
-    const menuMarkdown = this.menuFn({ files: _.concat(files, files2) });
31
+  public writeMenu(classContexts: ClassContext[], interfaceContexts: ClassContext[], enumContexts: EnumContext[]) {
32
+    const mapper = (c) => ({ name: c.name, path: `/api/${c.name}` });
33
+    const files = classContexts.map(mapper);
34
+    const files2 = interfaceContexts.map(mapper);
35
+    const files3 = enumContexts.map(mapper);
36
+
37
+    const menuMarkdown = this.menuFn({ files: _.concat(files, files2, files3) });
35
     fs.writeFileSync(`${this.outputDir}/_sidebar.md`, menuMarkdown, { encoding: 'utf8' });
38
     fs.writeFileSync(`${this.outputDir}/_sidebar.md`, menuMarkdown, { encoding: 'utf8' });
36
     fs.writeFileSync(`${this.outputDir}/README.md`, menuMarkdown, { encoding: 'utf8' });
39
     fs.writeFileSync(`${this.outputDir}/README.md`, menuMarkdown, { encoding: 'utf8' });
37
   }
40
   }

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

13
 
13
 
14
 export interface Reflections {
14
 export interface Reflections {
15
   classReflections: DeclarationReflection[];
15
   classReflections: DeclarationReflection[];
16
+  interfaceReflections: DeclarationReflection[];
16
   enumReflections: DeclarationReflection[];
17
   enumReflections: DeclarationReflection[];
17
 }
18
 }
18
 
19
 
32
 
33
 
33
     const externalModules = this.externalModulesWithoutTestsAndMocks(projectReflection);
34
     const externalModules = this.externalModulesWithoutTestsAndMocks(projectReflection);
34
     const classReflections = this.reflections(externalModules, ReflectionKind.Class);
35
     const classReflections = this.reflections(externalModules, ReflectionKind.Class);
36
+    const interfaceReflections = this.reflections(externalModules, ReflectionKind.Interface);
35
     const enumReflections = this.reflections(externalModules, ReflectionKind.Enum);
37
     const enumReflections = this.reflections(externalModules, ReflectionKind.Enum);
36
 
38
 
37
     return {
39
     return {
38
       classReflections,
40
       classReflections,
41
+      interfaceReflections,
39
       enumReflections
42
       enumReflections
40
     };
43
     };
41
   }
44
   }