From d133b41b0e911ee4afeceae0930277b32e32b440 Mon Sep 17 00:00:00 2001 From: Nan Wang Date: Thu, 3 Aug 2017 16:26:13 +0800 Subject: [PATCH 1/6] update firedoc to work with gitbook --- .gitignore | 1 + lib/ast.js | 6 +++ lib/ast/digesters.js | 1 + lib/helpers.js | 10 +++++ lib/locals.js | 11 ++++- lib/utils.js | 2 +- package.json | 3 +- themes/markdown/layouts/main.mdt | 13 ------ themes/markdown/partials/attrs.mdt | 2 +- themes/markdown/partials/class.mdt | 4 +- themes/markdown/partials/enum.mdt | 2 +- themes/markdown/partials/events.mdt | 2 +- themes/markdown/partials/items-index.mdt | 36 --------------- themes/markdown/partials/method.mdt | 5 ++- themes/markdown/partials/module.mdt | 56 +++++++++++++++++++++--- themes/markdown/partials/props.mdt | 2 +- yuidoc.json | 20 +++++++++ 17 files changed, 111 insertions(+), 65 deletions(-) create mode 100644 yuidoc.json diff --git a/.gitignore b/.gitignore index 794d745a..c3ffa34e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ npm-debug.log docs-ghpages bower_components +.vscode/ diff --git a/lib/ast.js b/lib/ast.js index 3b5db2e1..40c762c8 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -100,6 +100,11 @@ var AST = { */ classes: {}, + /** + * @property {Object} classes - The classes + */ + enums: {}, + /** * @property {Array} members - The members */ @@ -168,6 +173,7 @@ var AST = { AST.codes = {}; AST.modules = {}; AST.classes = {}; + AST.enums = {}; AST.members = []; AST.inheritedMembers = []; AST.commentsMap = {}; diff --git a/lib/ast/digesters.js b/lib/ast/digesters.js index af5ea09e..5d2ed1c6 100644 --- a/lib/ast/digesters.js +++ b/lib/ast/digesters.js @@ -382,6 +382,7 @@ module.exports = { if (tagname === 'enum') { host.isEnum = true; host.type = 'enums'; + this.enums[fullname] = host; } else { host.isEnum = false; host.type = 'classes'; diff --git a/lib/helpers.js b/lib/helpers.js index 3e1f4827..10258a43 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -110,3 +110,13 @@ exports.shouldShowInherit = function shouldShowInherit (item, options) { return options.inverse(this); } }; + +exports.getSourceFile = function getSourceFile (item, options) { + var sourceURL = this.options.sourceURL; + var org = sourceURL.org, repo = sourceURL.repo, branch = sourceURL.branch; + var path = require('path'); + var relativePath = item.replace(this.options.paths[0], '').replace('//', '/'); + var baseStr = `https://github.com/${org}/${repo}/blob/${branch}`; + var result = path.join(baseStr, relativePath); + return result; +} diff --git a/lib/locals.js b/lib/locals.js index ed633752..083407fa 100644 --- a/lib/locals.js +++ b/lib/locals.js @@ -233,6 +233,15 @@ var Locals = { markdown: function (data) { var self = this; if (this.options.markdown) { + if (data.indexOf('{{#crossLink') > -1) { + // console.log('==========crosslink==========\n' + data); + var regex = /({{#crossLink\w*\s".*"}}.*{{\/crossLink\w*}})/g; + var result = data.replace(regex, function(match) { + return (Handlebars.compile(match))({}); + }); + // console.log('result: ' + result); + return result; + } return data; } var html = _.unescape(md.render(data || '')); @@ -342,7 +351,7 @@ var Locals = { } if (this.options.markdown) { - member.markdownLink = utils.markdownLink(member.itemtype + ':' + member.name); + member.markdownLink = utils.markdownLink(member.name); } if (member.example) { if (!_.isArray(member.example)) { diff --git a/lib/utils.js b/lib/utils.js index 8bb98e57..ca1d76ef 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -373,7 +373,7 @@ exports.localize = localize; function markdownLink (str) { return str .replace(/[:,]/g, '-') - .replace(/[\s\(\)\[\]=]/g, '') + .replace(/[\s\(\)\[\]=_]/g, '') .toLowerCase(); } exports.markdownLink = markdownLink; diff --git a/package.json b/package.json index bd7817b9..41936519 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,8 @@ }, "scripts": { "docs": "make docs", - "test": "make test.nocoverage" + "test": "make test.nocoverage", + "build-api": "node ./bin/firedoc.js build -M --lang zh" }, "preferGlobal": "true", "licenses": [ diff --git a/themes/markdown/layouts/main.mdt b/themes/markdown/layouts/main.mdt index a15ddff3..47dd1df6 100644 --- a/themes/markdown/layouts/main.mdt +++ b/themes/markdown/layouts/main.mdt @@ -1,14 +1 @@ - -{{#if globals.project.name}} -# {{globals.project.name}} {{globals.project.version}} -{{else}} -# Fireball Engine API -{{/if}} - -{{#if project.description}} -{{project.description}} -{{else}} -Fireball is the game engine for the future. -{{/if}} - {{> layout_content}} diff --git a/themes/markdown/partials/attrs.mdt b/themes/markdown/partials/attrs.mdt index 53db9a05..a9ceeec8 100644 --- a/themes/markdown/partials/attrs.mdt +++ b/themes/markdown/partials/attrs.mdt @@ -7,7 +7,7 @@ {{#if extended_from}} > Inherited from `{{extended_from}}` {{/if}} -Defined in `{{{file}}}:{{{line}}}` +Defined in [{{getSourceFile file}}:{{{line}}}]({{getSourceFile file}}#L{{{line}}}) {{/if}} {{#if deprecationMessage}} diff --git a/themes/markdown/partials/class.mdt b/themes/markdown/partials/class.mdt index 79c6dafc..f1bcb79d 100644 --- a/themes/markdown/partials/class.mdt +++ b/themes/markdown/partials/class.mdt @@ -1,11 +1,11 @@ -### `{{name}}` Class +## `{{name}}` Class {{#if extends}} Extends `{{extends}}` {{/if}} {{#if foundAt}} -Defined in: [{{{file}}}:{{{line}}}](../files/{{{file}}}.js) +Defined in: [{{getSourceFile file}}:{{{line}}}]({{getSourceFile file}}#L{{{line}}}) {{/if}} {{#if module}} diff --git a/themes/markdown/partials/enum.mdt b/themes/markdown/partials/enum.mdt index 996154bf..07811be4 100644 --- a/themes/markdown/partials/enum.mdt +++ b/themes/markdown/partials/enum.mdt @@ -5,7 +5,7 @@ Extends `{{extends}}` {{/if}} {{#if foundAt}} -Defined in: [{{{file}}}:{{{line}}}](../files/{{{file}}}.js) +Defined in: [{{getSourceFile file}}:{{{line}}}]({{getSourceFile file}}#L{{{line}}}) {{/if}} {{#if module}} diff --git a/themes/markdown/partials/events.mdt b/themes/markdown/partials/events.mdt index 7aa366a9..82fa1ea7 100644 --- a/themes/markdown/partials/events.mdt +++ b/themes/markdown/partials/events.mdt @@ -5,7 +5,7 @@ Extends `{{extends}}` {{/if}} {{#if foundAt}} -Defined in: [{{{file}}}:{{{line}}}]({{foundAt}}) +Defined in: [{{getSourceFile file}}:{{{line}}}]({{getSourceFile file}}#L{{{line}}}) {{/if}} {{#if module}} diff --git a/themes/markdown/partials/items-index.mdt b/themes/markdown/partials/items-index.mdt index 98c8011b..19e62e8e 100644 --- a/themes/markdown/partials/items-index.mdt +++ b/themes/markdown/partials/items-index.mdt @@ -38,40 +38,4 @@ - [`{{name}}`](#{{markdownLink}}) {{{description}}} {{/members.events}} -{{/if}} - -{{#if members.inherited}} - -### Inherited members - -##### Properties - -{{#members.inherited.properties}} -- [`{{name}}`](#{{markdownLink}}) -{{/members.inherited.properties}} - -##### Attributes - -{{#members.inherited.attributes}} -- [`{{name}}`](#{{markdownLink}}) -{{/members.inherited.attributes}} - -##### Methods - -{{#members.inherited.methods}} -- [`{{methodName}}`](#{{markdownLink}}) -{{/members.inherited.methods}} - -##### Events - -{{#members.inherited.events}} -- [`{{name}}`](#{{markdownLink}}) -{{/members.inherited.events}} - -{{/if}} - -{{#if children}} - -### Inheritance tree - {{/if}} \ No newline at end of file diff --git a/themes/markdown/partials/method.mdt b/themes/markdown/partials/method.mdt index 22e5a210..55299c8b 100644 --- a/themes/markdown/partials/method.mdt +++ b/themes/markdown/partials/method.mdt @@ -12,7 +12,7 @@ | Extends | `{{extended_from}}` | {{/if}} {{/if}} -| Defined | [{{{file}}}:{{{line}}}]({{foundAt}}) | +| Defined | [{{getSourceFile file}}:{{{line}}}]({{getSourceFile file}}#L{{{line}}}) | {{#if deprecationMessage}} | Deprecated | {{deprecationMessage}} | {{/if}} @@ -44,6 +44,7 @@ {{/if}} {{#example}} -**Examples** +##### Example + {{{.}}} {{/example}} diff --git a/themes/markdown/partials/module.mdt b/themes/markdown/partials/module.mdt index 4a7f1a6d..ee5218cf 100644 --- a/themes/markdown/partials/module.mdt +++ b/themes/markdown/partials/module.mdt @@ -15,7 +15,7 @@ {{/if}} {{#if foundAt}} -Defined in [{{{file}}}:{{{line}}}]({{foundAt}}) +Defined in [{{getSourceFile file}}:{{{line}}}]({{getSourceFile file}}#L{{{line}}}) {{/if}} {{#if since}} @@ -44,13 +44,13 @@ This module is deprecated. {{/classes}} {{/if}} -{{#if classes}} +{{#if meta.enums}} ### Enums - {{#classes}} + {{#meta.enums}} {{#if is_enum}} - [{{name}}](../enums/{{name}}.md) {{/if}} - {{/classes}} + {{/meta.enums}} {{/if}} {{#if subModules}} @@ -61,6 +61,52 @@ This module is deprecated. {{/if}} {{#if members}} -### Direct Members {{> items-index}} +{{/if}} + +### Details + +{{#if members.properties}} + +#### Properties + +{{#members.properties}} +{{> props}} +{{/members.properties}} + +{{/if}} + +{{#if members.attributes}} + +#### Attributes + +{{#members.attributes}} +{{> attrs}} +{{/members.attributes}} + +{{/if}} + +{{#if members.methods}} + + +#### Methods + +{{#is_constructor}} +##### Constructor +{{> method}} +{{/is_constructor}} +{{#members.methods}} +{{> method}} +{{/members.methods}} + +{{/if}} + +{{#if members.events}} + +#### Events + +{{#members.events}} +{{> events}} +{{/members.events}} + {{/if}} \ No newline at end of file diff --git a/themes/markdown/partials/props.mdt b/themes/markdown/partials/props.mdt index 6d65f898..36d28294 100644 --- a/themes/markdown/partials/props.mdt +++ b/themes/markdown/partials/props.mdt @@ -13,7 +13,7 @@ | Extends | `{{extended_from}}` | {{/if}} {{/if}} -| Defined | [{{{file}}}:{{{line}}}]({{foundAt}}) | +| Defined | [{{getSourceFile file}}:{{{line}}}]({{getSourceFile file}}#L{{{line}}}) | {{#if deprecationMessage}} | Deprecated | {{deprecationMessage}} | {{/if}} diff --git a/yuidoc.json b/yuidoc.json new file mode 100644 index 00000000..1d4331b4 --- /dev/null +++ b/yuidoc.json @@ -0,0 +1,20 @@ +{ + "name": "Cocos Creator API", + "description": "", + "version": "1.5.x", + "url": "http://cocos.com/creator", + "logo": "", + "options": { + "outdir": "../../creator-api-doc/zh", + "sourceURL": { + "org": "cocos-creator", + "repo": "engine", + "branch": "master" + }, + "linkNatives": true, + "paths": [ + "../../fbnew/utils/api/engine" + ], + "tabtospace": 4 + } +} From ec598a9783531016349693aab994ede98526804d Mon Sep 17 00:00:00 2001 From: Nan Wang Date: Thu, 3 Aug 2017 19:23:15 +0800 Subject: [PATCH 2/6] fix enums not display correctlly issue --- lib/ast.js | 6 ------ lib/ast/digesters.js | 1 - lib/builder.js | 8 +++++++- lib/helpers.js | 10 ++++++++- lib/locals.js | 4 ++++ package.json | 3 ++- themes/markdown/partials/class.mdt | 2 +- themes/markdown/partials/index.mdt | 32 ++++++++++++++++++----------- themes/markdown/partials/module.mdt | 13 +++++++----- yuidoc.json | 3 ++- 10 files changed, 53 insertions(+), 29 deletions(-) diff --git a/lib/ast.js b/lib/ast.js index 40c762c8..3b5db2e1 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -100,11 +100,6 @@ var AST = { */ classes: {}, - /** - * @property {Object} classes - The classes - */ - enums: {}, - /** * @property {Array} members - The members */ @@ -173,7 +168,6 @@ var AST = { AST.codes = {}; AST.modules = {}; AST.classes = {}; - AST.enums = {}; AST.members = []; AST.inheritedMembers = []; AST.commentsMap = {}; diff --git a/lib/ast/digesters.js b/lib/ast/digesters.js index 5d2ed1c6..af5ea09e 100644 --- a/lib/ast/digesters.js +++ b/lib/ast/digesters.js @@ -382,7 +382,6 @@ module.exports = { if (tagname === 'enum') { host.isEnum = true; host.type = 'enums'; - this.enums[fullname] = host; } else { host.isEnum = false; host.type = 'classes'; diff --git a/lib/builder.js b/lib/builder.js index 2f5b42c3..a00589a2 100644 --- a/lib/builder.js +++ b/lib/builder.js @@ -325,6 +325,11 @@ var BuilderContext = { mod.type = 'modules'; mod.submodules = _.sortBy(submodules, 'name'); } + if (mod.classes.length > 0) { + mod.hasClasses = true; + } else { + mod.hasClasses = false; + } }); opts.meta.modules = _.sortBy(modules, 'name'); return opts; @@ -634,7 +639,7 @@ var BuilderContext = { var view = new DocView(locals.meta); view.base = '.'; var html = this.render('index', view, locals); - var filename = this.options.markdown ? '/readme.md' : '/index.html'; + var filename = this.options.markdown ? '/index.md' : '/index.html'; var dest = this.options.dest + filename; debug('Start writing index.html'); @@ -710,6 +715,7 @@ var BuilderContext = { locals.meta.modules, function (mod) { mod.globals = locals.meta; + mod.enums = locals.meta.enums; var view = new DocView(mod, null, '../'); var dest = path.join(self.options.dest, 'modules', mod.name + self.extname); view.base = '..'; diff --git a/lib/helpers.js b/lib/helpers.js index 10258a43..11dbaf3c 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -119,4 +119,12 @@ exports.getSourceFile = function getSourceFile (item, options) { var baseStr = `https://github.com/${org}/${repo}/blob/${branch}`; var result = path.join(baseStr, relativePath); return result; -} +}; + +exports.getVersion = function getVersion () { + return this.options.version; +}; + +exports.encodeName = function encodeName (item, options) { + return encodeURI(item); +}; \ No newline at end of file diff --git a/lib/locals.js b/lib/locals.js index 083407fa..4871bd5d 100644 --- a/lib/locals.js +++ b/lib/locals.js @@ -274,6 +274,10 @@ var Locals = { if (mod) { if (!_.isArray(mod.classes)) mod.classes = []; mod.classes.push(clazz); + if (clazz.isEnum) { + // for markdown template checking whether should render enum section + mod.hasEnum = true; + } } return clazz; }, diff --git a/package.json b/package.json index 41936519..26e9f940 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,8 @@ "scripts": { "docs": "make docs", "test": "make test.nocoverage", - "build-api": "node ./bin/firedoc.js build -M --lang zh" + "build-api": "node ./bin/firedoc.js build -M --lang zh", + "build-api-en": "node ./bin/firedoc.js build -M --lang en" }, "preferGlobal": "true", "licenses": [ diff --git a/themes/markdown/partials/class.mdt b/themes/markdown/partials/class.mdt index f1bcb79d..cb94e71d 100644 --- a/themes/markdown/partials/class.mdt +++ b/themes/markdown/partials/class.mdt @@ -1,7 +1,7 @@ ## `{{name}}` Class {{#if extends}} -Extends `{{extends}}` +Extends [`{{extends}}`]({{extends}}.md) {{/if}} {{#if foundAt}} diff --git a/themes/markdown/partials/index.mdt b/themes/markdown/partials/index.mdt index ccd57eef..fbb5cfc2 100644 --- a/themes/markdown/partials/index.mdt +++ b/themes/markdown/partials/index.mdt @@ -1,23 +1,31 @@ +# Index -{{#if enums}} -### Enums -{{#enums}} -{{#if is_enum}} -- [`{{name}}`](enums/{{name}}.md) from [{{module}}](modules/{{module}}.md) -{{/if}} -{{/enums}} +Cocos Creator v{{getVersion}} + +Welcome to Cocos Creator JavaScript engine API reference. You can search anything in top left search filed. + +All enums and classes are under `cc` module if not specified otherwise. + +{{#if modules}} +### Module + +{{#modules}} +- [`{{name}}`](modules/{{encodeName name}}.md) +{{/modules}} {{/if}} {{#if classes}} ### Classes + {{#classes}} - [`{{name}}`](classes/{{name}}.md) from [{{module}}](modules/{{module}}.md) {{/classes}} {{/if}} -{{#if modules}} -### Module -{{#modules}} -- [`{{name}}`](modules/{{name}}.md) -{{/modules}} +{{#if enums}} +### Enums + +{{#enums}} +- [`{{name}}`](enums/{{name}}.md) from [{{module}}](modules/{{module}}.md) +{{/enums}} {{/if}} diff --git a/themes/markdown/partials/module.mdt b/themes/markdown/partials/module.mdt index ee5218cf..2c3e3bef 100644 --- a/themes/markdown/partials/module.mdt +++ b/themes/markdown/partials/module.mdt @@ -37,24 +37,27 @@ This module is deprecated. {{{.}}} {{/example}} -{{#if classes}} +{{#if hasClasses}} ### Classes + {{#classes}} - [{{name}}](../classes/{{name}}.md) {{/classes}} {{/if}} -{{#if meta.enums}} +{{#if hasEnum}} ### Enums - {{#meta.enums}} - {{#if is_enum}} + + {{#classes}} + {{#if isEnum}} - [{{name}}](../enums/{{name}}.md) {{/if}} - {{/meta.enums}} + {{/classes}} {{/if}} {{#if subModules}} ### Sub Modules + {{#subModules}} - [{{name}}]({{name}}.md) {{{description}}} {{/subModules}} diff --git a/yuidoc.json b/yuidoc.json index 1d4331b4..6d6bc074 100644 --- a/yuidoc.json +++ b/yuidoc.json @@ -5,7 +5,8 @@ "url": "http://cocos.com/creator", "logo": "", "options": { - "outdir": "../../creator-api-doc/zh", + "version": "1.5.x", + "outdir": "../../creator-api-doc/en", "sourceURL": { "org": "cocos-creator", "repo": "engine", From ef1aef19a490e9291cf51b5a82d406da59ceff85 Mon Sep 17 00:00:00 2001 From: Nan Wang Date: Fri, 4 Aug 2017 18:39:59 +0800 Subject: [PATCH 3/6] add class and members sorting --- lib/builder.js | 19 +++++++++++++++++++ lib/helpers.js | 2 +- lib/locals.js | 5 +++-- yuidoc.json | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/builder.js b/lib/builder.js index a00589a2..9c627bd5 100644 --- a/lib/builder.js +++ b/lib/builder.js @@ -292,6 +292,7 @@ var BuilderContext = { debug('skipping class ' + clazz.name); return; } + clazz.members.sort(compareEntries); if (clazz.isEnum) { clazz.type = 'enums'; enums.push(clazz); @@ -300,6 +301,8 @@ var BuilderContext = { classes.push(clazz); } }); + classes.sort(compareEntries); + enums.sort(compareEntries); opts.meta.classes = classes; opts.meta.enums = enums; return opts; @@ -330,6 +333,9 @@ var BuilderContext = { } else { mod.hasClasses = false; } + if (mod.members) { + mod.members.sort(compareEntries); + } }); opts.meta.modules = _.sortBy(modules, 'name'); return opts; @@ -735,6 +741,19 @@ var BuilderContext = { var emitter = new EventEmitter(); BuilderContext = _.extend(BuilderContext, emitter); +// sorting entries +function compareEntries (a, b) { + var nameA = a.name.toLowerCase(); + var nameB = b.name.toLowerCase(); + if (nameA < nameB) { + return -1; + } + if (nameA > nameB) { + return 1; + } + return 0; +} + /** * Function to link an external type uses `NATIVES` object * @method NATIVES_LINKER diff --git a/lib/helpers.js b/lib/helpers.js index 11dbaf3c..10260692 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -47,7 +47,7 @@ exports.crossLink = function oncrossLink (item, options) { _.each(parts, function (i) { p.push(this._parseCrossLink.call(this, i)); }, this); - str = p.join(' | '); + str = p.join(' | '); } else { var ctx = ''; if (typeof options.fn === 'function') { diff --git a/lib/locals.js b/lib/locals.js index 4871bd5d..78b846cf 100644 --- a/lib/locals.js +++ b/lib/locals.js @@ -220,6 +220,9 @@ var Locals = { html = html.replace(/
/g, '
\n');
     // TODO(Yorkie): request to underscore, this is not working with '
     html = html.replace(/'/g, '\'');
+    if (this.options.markdown) {
+      html = html.replace(/&#(\d+);/g, function (m, p) { return String.fromCharCode(p); });
+    }
     return _.unescape(html);
   },
 
@@ -234,12 +237,10 @@ var Locals = {
     var self = this;
     if (this.options.markdown) {
       if (data.indexOf('{{#crossLink') > -1) {
-        // console.log('==========crosslink==========\n' + data);
         var regex = /({{#crossLink\w*\s".*"}}.*{{\/crossLink\w*}})/g;
         var result = data.replace(regex, function(match) {
           return (Handlebars.compile(match))({});
         });
-        // console.log('result: ' + result);
         return result;
       }
       return data;
diff --git a/yuidoc.json b/yuidoc.json
index 6d6bc074..fe3f6f1b 100644
--- a/yuidoc.json
+++ b/yuidoc.json
@@ -6,7 +6,7 @@
   "logo": "",
   "options": {
     "version": "1.5.x",
-    "outdir": "../../creator-api-doc/en",
+    "outdir": "../../creator-api-doc/zh",
     "sourceURL": {
         "org": "cocos-creator",
         "repo": "engine",

From c8bcb72aaba71ac9124488556e647357a1dbdae1 Mon Sep 17 00:00:00 2001
From: Coco 
Date: Thu, 10 May 2018 18:20:53 +0800
Subject: [PATCH 4/6] correct the link path

---
 lib/helpers.js | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/helpers.js b/lib/helpers.js
index 10260692..b739e86a 100644
--- a/lib/helpers.js
+++ b/lib/helpers.js
@@ -115,10 +115,9 @@ exports.getSourceFile = function getSourceFile (item, options) {
   var sourceURL = this.options.sourceURL;
   var org = sourceURL.org, repo = sourceURL.repo, branch = sourceURL.branch;
   var path = require('path');
-  var relativePath = item.replace(this.options.paths[0], '').replace('//', '/');
-  var baseStr = `https://github.com/${org}/${repo}/blob/${branch}`;
-  var result = path.join(baseStr, relativePath);
-  return result;
+  var relativePath = path.relative(path.join(this.options.paths[0], repo), item).replace(/\\/g, '/');
+  var baseStr = `https://github.com/${org}/${repo}/blob/${branch}/` + relativePath;
+  return baseStr;
 };
 
 exports.getVersion = function getVersion () {

From 809bd0761ffbeba742322fd60f1ce0d0bb55ac4d Mon Sep 17 00:00:00 2001
From: Coco 
Date: Mon, 21 May 2018 14:36:03 +0800
Subject: [PATCH 5/6] correct the cc.md classes disappear

---
 lib/builder.js | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lib/builder.js b/lib/builder.js
index 9c627bd5..7d169b48 100644
--- a/lib/builder.js
+++ b/lib/builder.js
@@ -330,6 +330,20 @@ var BuilderContext = {
       }
       if (mod.classes.length > 0) {
         mod.hasClasses = true;
+        var classes = [];
+        var enums = [];
+        _.each(mod.classes, function (obj) {
+          if (obj.isEnum) {
+            enums.push(obj);
+          }
+          else {
+            classes.push(obj);
+          }
+        }); 
+        classes.sort(compareEntries);
+        enums.sort(compareEntries);
+        mod.classes = classes;
+        mod.enums = enums;
       } else {
         mod.hasClasses = false;
       }

From f4ff60f9a06f9627af861dc81f9908d44a4f7175 Mon Sep 17 00:00:00 2001
From: Coco 
Date: Wed, 23 May 2018 14:36:40 +0800
Subject: [PATCH 6/6] change the branch name to commit id

---
 lib/firedoc.js | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/firedoc.js b/lib/firedoc.js
index 18ca99ae..fcfb9302 100755
--- a/lib/firedoc.js
+++ b/lib/firedoc.js
@@ -85,6 +85,16 @@ function Firedoc (config) {
   if (fs.existsSync(cwd + '/yuidoc.json')) {
     pkg = require(cwd + '/yuidoc.json');
     firedocOptions = pkg.options;
+    // change the default branch (master) to commit id. 
+    var myPath = __dirname.replace(/\\node_modules\\.+/, '');
+    myPath = path.resolve(myPath, './../engine');
+    var command = spawn('git', ['log','--format="%H"', '-n' ,'1'], {
+        cwd: myPath,
+    });
+    command.stdout.on('data', function (data) {
+      firedocOptions.sourceURL.branch = data.toString().trim().replace(/"/g, '');
+    });
+
     delete pkg.options;
   } else if (fs.existsSync(cwd + '/package.json')) {
     pkg = require(cwd + '/package.json');