Skip to content

Commit

Permalink
feat(partials): add the possibility to change jsdoc2markdown partials
Browse files Browse the repository at this point in the history
update dependencies
  • Loading branch information
ph1p committed Mar 15, 2020
1 parent cff3910 commit ab158aa
Show file tree
Hide file tree
Showing 19 changed files with 2,254 additions and 1,822 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ If no command passed it will run `generate` as default
| --readme | -r | | Path to custom readme file |
| --exclude | -e | | Pattern to exclude files/folders (Comma seperated) - \*.test.js,exclude.js |
| --rmPattern | -rm | | Pattern when removing files. You can ex- and include files. (glob pattern) |
| --partials | -p | | jsdoc2markdown partial templates (overwrites default ones) |
| --jsDocConfigPath | -c | | Path to [JsDoc Config](http://usejsdoc.org/about-configuring-jsdoc.html) (experimental) |

### config.js
Expand Down
4 changes: 3 additions & 1 deletion cmds/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ async function generate(argv) {
const title = argv.title;
const readme = argv.readme;
const rmPattern = argv.rmPattern || [];
const partials = argv.partials || [];

// remove docs folder, except README.md
const deletedPaths = await del([docsFolder + '/**/*', `!${docsFolder}/README.md`, ...rmPattern]);
Expand Down Expand Up @@ -112,7 +113,8 @@ async function generate(argv) {
configure: configPath,
partial: [
path.resolve(__filename, '../../template/header.hbs'),
path.resolve(__filename, '../../template/main.hbs')
path.resolve(__filename, '../../template/main.hbs'),
...partials
]
});
} catch (e) {
Expand Down
21 changes: 14 additions & 7 deletions example/documentation/code/class-constructor.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,34 @@ title: Classes

<a name="firstClass"></a>

## firstClassfirstClass (no annotation needed)
## firstClass
firstClass (no annotation needed)

**Kind**: global class
<a name="secondClass"></a>

## secondClass**Kind**: global class
## secondClass
**Kind**: global class
<a name="new_secondClass_new"></a>

### new secondClass()secondClass
### new secondClass()
secondClass

<a name="thirdClass"></a>

## thirdClass**Kind**: global class
## thirdClass
**Kind**: global class
<a name="new_thirdClass_new"></a>

### new thirdClass()thirdClass
### new thirdClass()
thirdClass

<a name="fourthClass"></a>

## fourthClass**Kind**: global class
## fourthClass
**Kind**: global class
<a name="new_fourthClass_new"></a>

### new fourthClass()fourthClass (no class annotation)
### new fourthClass()
fourthClass (no class annotation)

21 changes: 14 additions & 7 deletions example/documentation/code/class.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ test: test class

<a name="Test"></a>

## Test**Kind**: global class
## Test
**Kind**: global class

* [Test](#Test)
* [new Test()](#new_Test_new)
Expand All @@ -21,30 +22,36 @@ test: test class

<a name="new_Test_new"></a>

### new Test()This is a test class
### new Test()
This is a test class

<a name="Test+name"></a>

### test.nameSet current name
### test.name
Set current name

**Kind**: instance property of [<code>Test</code>](#Test)
<a name="Test+name"></a>

### test.nameGet current name
### test.name
Get current name

**Kind**: instance property of [<code>Test</code>](#Test)
<a name="Test+generateFullName"></a>

### test.generateFullName() ⇒Generate a fullname
### test.generateFullName() ->
Generate a fullname

**Kind**: instance method of [<code>Test</code>](#Test)
**Returns**: an string
<a name="Test.Test"></a>

### Test.Test**Kind**: static class of [<code>Test</code>](#Test)
### Test.Test
**Kind**: static class of [<code>Test</code>](#Test)
<a name="new_Test.Test_new"></a>

#### new Test([name])Creates an instance of Test.
#### new Test([name])
Creates an instance of Test.


| Param | Type | Default |
Expand Down
3 changes: 2 additions & 1 deletion example/documentation/code/lib/dmd-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ title: dmd-options

<a name="DmdOptions"></a>

## DmdOptions**Kind**: global class
## DmdOptions
**Kind**: global class
30 changes: 20 additions & 10 deletions example/documentation/code/lib/jsdoc-to-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ title: jsdoc-to-markdown

<a name="module_jsdoc-to-markdown"></a>

## jsdoc-to-markdown**Example**
## jsdoc-to-markdown
**Example**
```js
const jsdoc2md = require('jsdoc-to-markdown')
```
Expand All @@ -26,10 +27,12 @@ const jsdoc2md = require('jsdoc-to-markdown')

<a name="exp_module_jsdoc-to-markdown--JsdocToMarkdown"></a>

### JsdocToMarkdown ⏏**Kind**: Exported class
### JsdocToMarkdown ⏏
**Kind**: Exported class
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+render"></a>

#### jsdoc2md.render([options]) ⇒ <code>Promise</code>Returns markdown documentation from jsdoc-annoted source code.
#### jsdoc2md.render([options]) -> <code>Promise</code>
Returns markdown documentation from jsdoc-annoted source code.

**Kind**: instance method of [<code>JsdocToMarkdown</code>](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)
**Category**: async
Expand Down Expand Up @@ -61,7 +64,8 @@ Pass in filepaths (`**` glob matching supported) of javascript source files:
```
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+getTemplateData"></a>

#### jsdoc2md.getTemplateData([options]) ⇒ <code>Promise</code>Returns the template data (jsdoc-parse output) which is fed into the output template (dmd).
#### jsdoc2md.getTemplateData([options]) -> <code>Promise</code>
Returns the template data (jsdoc-parse output) which is fed into the output template (dmd).

**Kind**: instance method of [<code>JsdocToMarkdown</code>](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)
**Category**: async
Expand All @@ -73,7 +77,8 @@ Pass in filepaths (`**` glob matching supported) of javascript source files:

<a name="module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocData"></a>

#### jsdoc2md.getJsdocData([options]) ⇒ <code>Promise</code>Returns raw data direct from the underlying [jsdoc3](https://github.com/jsdoc3/jsdoc).
#### jsdoc2md.getJsdocData([options]) -> <code>Promise</code>
Returns raw data direct from the underlying [jsdoc3](https://github.com/jsdoc3/jsdoc).

**Kind**: instance method of [<code>JsdocToMarkdown</code>](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)
**Category**: async
Expand All @@ -89,13 +94,15 @@ Pass in filepaths (`**` glob matching supported) of javascript source files:

<a name="module_jsdoc-to-markdown--JsdocToMarkdown+clear"></a>

#### jsdoc2md.clear() ⇒ <code>Promise</code>By default, the output of each invocation of the main generation methods (`render`, `getTemplateData` etc) is stored in the cache (your system's [temporary directory](https://nodejs.org/dist/latest-v6.x/docs/api/os.html#os_os_tmpdir)). Future jsdoc2md invocations with the same input options and source code will return the output immediately from cache, making the tool much faster/cheaper. If the input options or source code changes, fresh output will be generated. This method clears the cache, which you should never need to do unless the cache is failing for some reason. On Mac OSX, the system tmpdir clears itself every few days meaning your jsdoc2md cache will also be routinely cleared.
#### jsdoc2md.clear() -> <code>Promise</code>
By default, the output of each invocation of the main generation methods (`render`, `getTemplateData` etc) is stored in the cache (your system's [temporary directory](https://nodejs.org/dist/latest-v6.x/docs/api/os.html#os_os_tmpdir)). Future jsdoc2md invocations with the same input options and source code will return the output immediately from cache, making the tool much faster/cheaper. If the input options or source code changes, fresh output will be generated. This method clears the cache, which you should never need to do unless the cache is failing for some reason. On Mac OSX, the system tmpdir clears itself every few days meaning your jsdoc2md cache will also be routinely cleared.

**Kind**: instance method of [<code>JsdocToMarkdown</code>](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)
**Category**: async
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+getNamepaths"></a>

#### jsdoc2md.getNamepaths(options) ⇒ <code>object</code>Returns all [jsdoc namepaths](http://usejsdoc.org/about-namepaths.html) found in the supplied source code.
#### jsdoc2md.getNamepaths(options) -> <code>object</code>
Returns all [jsdoc namepaths](http://usejsdoc.org/about-namepaths.html) found in the supplied source code.

**Kind**: instance method of [<code>JsdocToMarkdown</code>](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)
**Category**: async
Expand All @@ -106,7 +113,8 @@ Pass in filepaths (`**` glob matching supported) of javascript source files:

<a name="module_jsdoc-to-markdown--JsdocToMarkdown+renderSync"></a>

#### jsdoc2md.renderSync([options]) ⇒ <code>string</code>Sync version of [render](#module_jsdoc-to-markdown--JsdocToMarkdown+render).
#### jsdoc2md.renderSync([options]) -> <code>string</code>
Sync version of [render](#module_jsdoc-to-markdown--JsdocToMarkdown+render).

**Kind**: instance method of [<code>JsdocToMarkdown</code>](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)
**Category**: sync
Expand All @@ -122,7 +130,8 @@ const docs = jsdoc2md.renderSync({ files: 'lib/*.js' })
```
<a name="module_jsdoc-to-markdown--JsdocToMarkdown+getTemplateDataSync"></a>

#### jsdoc2md.getTemplateDataSync([options]) ⇒ <code>Array.&lt;object&gt;</code>Sync version of [getTemplateData](#module_jsdoc-to-markdown--JsdocToMarkdown+getTemplateData).
#### jsdoc2md.getTemplateDataSync([options]) -> <code>Array.&lt;object&gt;</code>
Sync version of [getTemplateData](#module_jsdoc-to-markdown--JsdocToMarkdown+getTemplateData).

**Kind**: instance method of [<code>JsdocToMarkdown</code>](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)
**Category**: sync
Expand All @@ -133,7 +142,8 @@ const docs = jsdoc2md.renderSync({ files: 'lib/*.js' })

<a name="module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocDataSync"></a>

#### jsdoc2md.getJsdocDataSync([options]) ⇒ <code>Array.&lt;object&gt;</code>Sync version of [getJsdocData](#module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocData).
#### jsdoc2md.getJsdocDataSync([options]) -> <code>Array.&lt;object&gt;</code>
Sync version of [getJsdocData](#module_jsdoc-to-markdown--JsdocToMarkdown+getJsdocData).

**Kind**: instance method of [<code>JsdocToMarkdown</code>](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)
**Category**: sync
Expand Down
19 changes: 12 additions & 7 deletions example/documentation/code/methods.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: A normal ES6 Method
title: A normal ES6 Methodf jdhsfkj dsfhdskjf dksjfhdks j
headline: Custom Title!
---

Expand All @@ -8,23 +8,28 @@ headline: Custom Title!
## Functions

<dl>
<dt><a href="#ES6Method">ES6Method()</a> </dt>
<dt><a href="#ES6Method">ES6Method(param)</a> -> <code>string</code></dt>
<dd><p>A normal ES6 Method</p>
</dd>
<dt><a href="#standardMethod">standardMethod()</a> </dt>
<dt><a href="#standardMethod">standardMethod()</a> -> <code>string</code></dt>
<dd><p>A normal standard Method</p>
</dd>
</dl>

<a name="ES6Method"></a>

## ES6Method() ⇒A normal ES6 Method
## ES6Method(param) -> <code>string</code>
A normal ES6 Method

**Kind**: global function
**Returns**: a String

| Param | Type |
| --- | --- |
| param | <code>string</code> |

<a name="standardMethod"></a>

## standardMethod() ⇒A normal standard Method
## standardMethod() -> <code>string</code>
A normal standard Method

**Kind**: global function
**Returns**: a String
12 changes: 8 additions & 4 deletions example/documentation/code/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ title: objects

<a name="obj"></a>

## objObject description
## obj
Object description

**Kind**: global constant

Expand All @@ -17,12 +18,14 @@ title: objects

<a name="obj.name"></a>

### obj.namename
### obj.name
name

**Kind**: static property of [<code>obj</code>](#obj)
<a name="obj.objMethod"></a>

### obj.objMethod(parameter) ⇒A function with a parameter and returns the name
### obj.objMethod(parameter) ->
A function with a parameter and returns the name

**Kind**: static method of [<code>obj</code>](#obj)
**Returns**: this.name
Expand All @@ -33,6 +36,7 @@ title: objects

<a name="obj.objMethodTwo"></a>

### obj.objMethodTwo()Old way to write methods in objects
### obj.objMethodTwo()
Old way to write methods in objects

**Kind**: static method of [<code>obj</code>](#obj)
6 changes: 4 additions & 2 deletions example/documentation/code/subfolder/subfolder.1/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ title: variables

<a name="normalLetVariable"></a>

## normalLetVariableA normal let variable
## normalLetVariable
A normal let variable

**Kind**: global variable
<a name="MY_CONST_VAR"></a>

## MY\_CONST\_VARSymbol constant
## MY\_CONST\_VAR
Symbol constant

**Kind**: global constant
6 changes: 4 additions & 2 deletions example/documentation/code/subfolder/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ title: variables

<a name="normalLetVariable"></a>

## normalLetVariableA normal let variable
## normalLetVariable
A normal let variable

**Kind**: global variable
<a name="SUBFOLDER"></a>

## SUBFOLDERA constant
## SUBFOLDER
A constant

**Kind**: global constant
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"docs": "../bin/vuepress-jsdoc.js --source=./src --dist=./documentation --title=API --exclude=*.test.js",
"docs": "../bin/vuepress-jsdoc.js --source=./src --dist=./documentation --title=API --exclude=*.test.js --partials=./partials/*.hbs",
"dev": "vuepress dev documentation",
"build": "vuepress build documentation"
},
Expand Down
14 changes: 14 additions & 0 deletions example/partials/sig-link-html.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{#if name}}{{#sig no-gfm=true ~}}
{{{@depOpen}~}}
<a href="#{{{anchorName}}}">
{{~{@codeOpen}~}}
{{#if @prefix}}{{@prefix}} {{/if~}}
{{@accessSymbol}}{{#if (isEvent)}}"{{{name}}}"{{else}}{{{name}}}{{/if~}}
{{~#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}}
{{{@codeClose}~}}
</a>
{{~#if @returnSymbol}} -> {{/if~}}
{{#if @returnTypes}} {{>linked-type-list types=@returnTypes html=true delimiter=" | " }}{{/if~}}
{{#if @suffix}} {{@suffix}}{{/if~}}
{{{@depClose}~}}
{{~/sig}}{{/if~}}
15 changes: 15 additions & 0 deletions example/partials/sig-name.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}}
{{#if name}}{{#sig~}}
{{{@depOpen}~}}
{{{@codeOpen}~}}
{{#if @prefix}}{{@prefix}} {{/if~}}
{{@parent~}}
{{@accessSymbol}}{{#if (isEvent)}}"{{{name}}}"{{else}}{{{escape name}}}{{/if~}}
{{#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}}
{{{@codeClose}~}}
{{#if @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~}}
Loading

0 comments on commit ab158aa

Please sign in to comment.