Browse Source

removed old docs generation, working on a side project to accomplish that

Daniel Zlotin 6 years ago
parent
commit
f63910e212
7 changed files with 3 additions and 149 deletions
  1. 0
    7
      docs/templates/class.hbs
  2. 0
    1
      docs/templates/main.hbs
  3. 0
    13
      docs/templates/method.hbs
  4. 3
    8
      package.json
  5. 0
    116
      scripts/gen-docs.ts
  6. 0
    1
      scripts/local-docs.js
  7. 0
    3
      tsn.sh

+ 0
- 7
docs/templates/class.hbs View File

@@ -1,7 +0,0 @@
1
-# {{name}}
2
-
3
-## Methods
4
-
5
-{{#each methods}}
6
-{{> method}}
7
-{{/each}}

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

@@ -1 +0,0 @@
1
-{{> class}}

+ 0
- 13
docs/templates/method.hbs View File

@@ -1,13 +0,0 @@
1
-### `{{name}}(arg0: x, arg1: y): {{returnValue}}`
2
-
3
-[source]({{source}})
4
-
5
-{{comment}}
6
-
7
-#### Arguments
8
-TBD
9
-
10
-#### Returns
11
-TBD
12
-
13
----

+ 3
- 8
package.json View File

@@ -44,7 +44,7 @@
44 44
     "prerelease": "npm run build",
45 45
     "release": "node ./scripts/release",
46 46
     "local-docs": "node ./scripts/local-docs",
47
-    "gen-docs": "./tsn.sh ./scripts/gen-docs"
47
+    "gen-docs": "echo 'This is a work in progress'"
48 48
   },
49 49
   "peerDependencies": {
50 50
     "react": "*",
@@ -53,14 +53,12 @@
53 53
   "dependencies": {
54 54
     "lodash": "4.x.x",
55 55
     "prop-types": "15.x.x",
56
-    "tslib": "1.x.x",
57 56
     "@types/react": "16.x.x",
58 57
     "@types/react-native": "0.49.x",
59 58
     "@types/lodash": "4.x.x",
60 59
     "@types/prop-types": "15.x.x",
61 60
     "@types/react-test-renderer": "16.x.x",
62
-    "@types/jest": "22.x.x",
63
-    "@types/node": "9.x.x"
61
+    "@types/jest": "22.x.x"
64 62
   },
65 63
   "devDependencies": {
66 64
     "detox": "7.x.x",
@@ -75,10 +73,7 @@
75 73
     "semver": "5.x.x",
76 74
     "shell-utils": "1.x.x",
77 75
     "tslint": "5.x.x",
78
-    "typescript": "2.x.x",
79
-    "ts-node": "5.x.x",
80
-    "typedoc": "0.x.x",
81
-    "handlebars": "4.x.x"
76
+    "typescript": "2.x.x"
82 77
   },
83 78
   "babel": {
84 79
     "env": {

+ 0
- 116
scripts/gen-docs.ts View File

@@ -1,116 +0,0 @@
1
-import * as _ from 'lodash';
2
-import * as Typedoc from 'typedoc';
3
-import * as Handlebars from 'handlebars';
4
-import * as fs from 'fs';
5
-
6
-const ROOT_DIR = `${__dirname}/..`;
7
-const SRC_DIR = `${ROOT_DIR}/lib/src`;
8
-const DOCS_DIR = `${ROOT_DIR}/docs`;
9
-const TEMPLATES_DIR = `${DOCS_DIR}/templates`;
10
-const API_DIR = `${DOCS_DIR}/api`;
11
-
12
-class Main {
13
-  public generateApiDocsMarkdown() {
14
-    const moduleName = 'Navigation';
15
-    const reflections = new ReflectionsReader().read(moduleName);
16
-    const classRef = new Parser().parseClass(reflections);
17
-    new MarkdownCreator().create(classRef);
18
-  }
19
-}
20
-
21
-class MarkdownCreator {
22
-  private handlebarsFn: HandlebarsTemplateDelegate<any>;
23
-  constructor() {
24
-    this.handlebarsFn = this.setupHandlebars();
25
-  }
26
-
27
-  public create(context: ClassReflection) {
28
-
29
-    const result = this.handlebarsFn(context);
30
-
31
-    // console.log(result);
32
-    API_DIR.toString();
33
-  }
34
-
35
-  private setupHandlebars(): HandlebarsTemplateDelegate<any> {
36
-    const mainTemplate = readFile(`${TEMPLATES_DIR}/main.hbs`);
37
-    const classTemplate = readFile(`${TEMPLATES_DIR}/class.hbs`);
38
-    const methodTemplate = readFile(`${TEMPLATES_DIR}/method.hbs`);
39
-    Handlebars.registerPartial('class', classTemplate);
40
-    Handlebars.registerPartial('method', methodTemplate);
41
-    return Handlebars.compile(mainTemplate, { strict: true });
42
-  }
43
-}
44
-
45
-interface ClassReflection {
46
-  name: string;
47
-  methods: MethodReflection[];
48
-}
49
-
50
-interface MethodReflection {
51
-  name: string;
52
-  argumentValues: string[];
53
-  returnValue: string;
54
-  comment: string;
55
-  source: string;
56
-}
57
-
58
-class Parser {
59
-  public parseClass(reflections): ClassReflection {
60
-    const theModuleRaw = reflections.children[0];
61
-    const theClassRaw = theModuleRaw.children[0];
62
-
63
-    const methods = this.parseMethods(theClassRaw);
64
-    const result = {
65
-      name: theClassRaw.name,
66
-      methods
67
-    };
68
-    return result;
69
-  }
70
-
71
-  private parseMethods(theClassRaw): MethodReflection[] {
72
-    const methodsRaw = _.filter(theClassRaw.children, (child) => child.kind === Typedoc.ReflectionKind.Method);
73
-    methodsRaw.toString();
74
-    const result = [{
75
-      name: 'theName',
76
-      argumentValues: ['asd', 'zxc'],
77
-      returnValue: 'returnVal',
78
-      comment: 'bla bla bla',
79
-      source: 'fromHere'
80
-    }];
81
-
82
-    return result;
83
-  }
84
-}
85
-
86
-class ReflectionsReader {
87
-  private typedocApp: Typedoc.Application;
88
-  constructor() {
89
-    const tsconfig = JSON.parse(readFile(`${ROOT_DIR}/tsconfig.json`));
90
-    this.typedocApp = new Typedoc.Application({
91
-      excludeExternals: true,
92
-      excludePrivate: true,
93
-      excludeProtected: true,
94
-      includeDeclarations: true,
95
-      module: 'commonjs',
96
-      readme: 'none',
97
-      target: 'ES6',
98
-      ...tsconfig.compilerOptions
99
-    });
100
-  }
101
-  read(moduleName) {
102
-    return this.typedocApp.serializer.projectToObject(
103
-      this.typedocApp.convert(
104
-        this.typedocApp.expandInputFiles(
105
-          [`${SRC_DIR}/${moduleName}.ts`]
106
-        )
107
-      )
108
-    );
109
-  }
110
-}
111
-
112
-function readFile(f) {
113
-  return fs.readFileSync(f).toString();
114
-}
115
-
116
-new Main().generateApiDocsMarkdown();

+ 0
- 1
scripts/local-docs.js View File

@@ -8,7 +8,6 @@ const ROOT = `${__dirname}/../docs`;
8 8
 run();
9 9
 
10 10
 function run() {
11
-
12 11
   http.createServer((req, res) => {
13 12
     console.log(req.url);
14 13
     const path = `${ROOT}${req.url === '/' ? '/index.html' : req.url}`;

+ 0
- 3
tsn.sh View File

@@ -1,3 +0,0 @@
1
-#!/bin/bash -e
2
-
3
-ts-node --typeCheck --compilerOptions '{"types":["node"]}' $1