Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/docs/options/BottomTabs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<a name="BottomTabs"></a>
<h1>BottomTabs</h1>

## BottomTabs
**Properties**

| Name | Type |
Expand Down
3 changes: 1 addition & 2 deletions docs/docs/options/Button.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<a name="Button"></a>
<h1>Button</h1>

## Button
**Properties**

| Name | Type |
Expand Down
3 changes: 1 addition & 2 deletions docs/docs/options/NavigationOptions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<a name="NavigationOptions"></a>
<h1>NavigationOptions</h1>

## NavigationOptions
**Properties**

| Name | Type |
Expand Down
3 changes: 1 addition & 2 deletions docs/docs/options/TopBar.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<a name="TopBar"></a>
<h1>TopBar</h1>

## TopBar
**Properties**

| Name | Type |
Expand Down
3 changes: 3 additions & 0 deletions docs/templates/header.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>{{anchorName}}</h1>

{{>sig-name}}
14 changes: 14 additions & 0 deletions docs/templates/sig-name.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}}
{{#if name}}{{#sig~}}
{{{@depOpen}~}}
{{{@codeOpen}~}}
{{#if @prefix}}{{@prefix}} {{/if~}}
{{@parent~}}
{{#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}}
{{{@codeClose}~}}
{{#if @returnSymbol}} {{@returnSymbol}}{{/if~}}
{{#if @returnTypes}} {{>linked-type-list types=@returnTypes delimiter=" \| " }}{{/if~}}
{{#if @suffix}} {{@suffix}}{{/if~}}
{{{@depClose}~}}
{{~/sig}}{{/if~}}
{{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}}
30 changes: 16 additions & 14 deletions scripts/generate-js-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ const jsdoc2md = require('jsdoc-to-markdown');
const fs = require('fs');
const path = require('path');

const paramsDir = './lib/src/params/';
const optionsDir = './lib/src/params/options/';
const PARAMS_DIR = './lib/src/params/';
const OPTIONS_DIR = './lib/src/params/options/';
const OUTPUT_DIR = './docs/docs/';
const partial = ['./docs/templates/scope.hbs', './docs/templates/docs.hbs'];
const OPTION_PARTIALS = ['./docs/templates/header.hbs', './docs/templates/sig-name.hbs'];
const PARTIALS = ['./docs/templates/scope.hbs', './docs/templates/docs.hbs'];

const generateMarkdownForFile = ({ file, outputDir }) => {
const generateMarkdownForFile = ({ file, outputDir, partial }) => {
const templateData = jsdoc2md.getTemplateDataSync({ files: file });
const classNames = getClassesInFile(templateData);
classNames.forEach((className) => createDocFileForClass(className, templateData, outputDir));
classNames.forEach((className) => createDocFileForClass({ className, templateData, outputDir, partial }));
};

function getClassesInFile(templateData) {
Expand All @@ -23,33 +24,34 @@ function getClassesInFile(templateData) {
return classNames;
}

function createDocFileForClass(className, templateData, outputDir) {
function createDocFileForClass({ className, templateData, outputDir, partial = [] }) {
const template = `{{#class name="${className}"}}{{>docs}}{{/class}}`;
const options = {
data: templateData,
template,
separators: true,
partial
partial: [...PARTIALS, ...partial]
};
console.log(`rendering ${className}, template: ${template} ${outputDir}`);
console.log(`rendering ${className}`);
const output = jsdoc2md.renderSync(options);
fs.writeFileSync(path.resolve(outputDir, `${className}.md`), output);
}

function inputFiles() {
return [
{ file: './lib/src/Navigation.js', outputDir: OUTPUT_DIR },
...fs.readdirSync(optionsDir).map((file) => {
...fs.readdirSync(OPTIONS_DIR).map((file) => {
return {
file: optionsDir + file,
outputDir: OUTPUT_DIR + 'options/'
file: OPTIONS_DIR + file,
outputDir: OUTPUT_DIR + 'options/',
partial: OPTION_PARTIALS
};
}),
...fs.readdirSync(paramsDir)
.filter((file) => fs.statSync(paramsDir + file).isFile())
...fs.readdirSync(PARAMS_DIR)
.filter((file) => fs.statSync(PARAMS_DIR + file).isFile())
.map((file) => {
return {
file: paramsDir + file,
file: PARAMS_DIR + file,
outputDir: OUTPUT_DIR
};
})
Expand Down