Quellcode durchsuchen

support interface docs

Daniel Zlotin vor 6 Jahren
Ursprung
Commit
fdcb7aad15

+ 11
- 0
docs/api/EventSubscription.md Datei anzeigen

@@ -0,0 +1,11 @@
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 Datei anzeigen

@@ -4,7 +4,7 @@
4 4
 
5 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,7 +12,7 @@
12 12
 
13 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,7 +20,7 @@
20 20
 
21 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,7 +28,7 @@
28 28
 
29 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,7 +36,7 @@
36 36
 
37 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 Datei anzeigen

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

+ 1
- 0
docs/api/_sidebar.md Datei anzeigen

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

+ 1
- 1
lib/src/adapters/NativeEventsReceiver.ts Datei anzeigen

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

+ 1
- 1
lib/src/events/CommandsObserver.ts Datei anzeigen

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

+ 1
- 4
lib/src/events/EventsRegistry.ts Datei anzeigen

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

+ 3
- 0
lib/src/interfaces/EventSubscription.ts Datei anzeigen

@@ -0,0 +1,3 @@
1
+export interface EventSubscription {
2
+  remove();
3
+}

+ 2
- 1
package.json Datei anzeigen

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

+ 6
- 2
scripts/gen-docs/Main.ts Datei anzeigen

@@ -14,14 +14,18 @@ const SOURCE_LINK_PREFIX = `https://github.com/wix/react-native-navigation/blob/
14 14
 class Main {
15 15
   public run() {
16 16
     const classParser = new ClassParser(SOURCE_LINK_PREFIX);
17
+    const enumParser = new EnumParser();
17 18
     const markdownWriter = new MarkdownWriter(TEMPLATES_DIR, OUTPUT_DIR);
18 19
     const reflections = new ReflectionsReader(TSCONFIG_PATH).read(INPUT_DIR);
19 20
 
20 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 25
     markdownWriter.writeClasses(parsedClasses);
26
+    markdownWriter.writeClasses(parsedInterfaces);
23 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 Datei anzeigen

@@ -28,10 +28,13 @@ export class MarkdownWriter {
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 38
     fs.writeFileSync(`${this.outputDir}/_sidebar.md`, menuMarkdown, { encoding: 'utf8' });
36 39
     fs.writeFileSync(`${this.outputDir}/README.md`, menuMarkdown, { encoding: 'utf8' });
37 40
   }

+ 3
- 0
scripts/gen-docs/ReflectionsReader.ts Datei anzeigen

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