Skip to content

Commit ab158aa

Browse files
committed
feat(partials): add the possibility to change jsdoc2markdown partials
update dependencies
1 parent cff3910 commit ab158aa

File tree

19 files changed

+2254
-1822
lines changed

19 files changed

+2254
-1822
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ If no command passed it will run `generate` as default
4343
| --readme | -r | | Path to custom readme file |
4444
| --exclude | -e | | Pattern to exclude files/folders (Comma seperated) - \*.test.js,exclude.js |
4545
| --rmPattern | -rm | | Pattern when removing files. You can ex- and include files. (glob pattern) |
46+
| --partials | -p | | jsdoc2markdown partial templates (overwrites default ones) |
4647
| --jsDocConfigPath | -c | | Path to [JsDoc Config](http://usejsdoc.org/about-configuring-jsdoc.html) (experimental) |
4748

4849
### config.js

cmds/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ async function generate(argv) {
2929
const title = argv.title;
3030
const readme = argv.readme;
3131
const rmPattern = argv.rmPattern || [];
32+
const partials = argv.partials || [];
3233

3334
// remove docs folder, except README.md
3435
const deletedPaths = await del([docsFolder + '/**/*', `!${docsFolder}/README.md`, ...rmPattern]);
@@ -112,7 +113,8 @@ async function generate(argv) {
112113
configure: configPath,
113114
partial: [
114115
path.resolve(__filename, '../../template/header.hbs'),
115-
path.resolve(__filename, '../../template/main.hbs')
116+
path.resolve(__filename, '../../template/main.hbs'),
117+
...partials
116118
]
117119
});
118120
} catch (e) {

example/documentation/code/class-constructor.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,34 @@ title: Classes
2020

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

23-
## firstClassfirstClass (no annotation needed)
23+
## firstClass
24+
firstClass (no annotation needed)
2425

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

28-
## secondClass**Kind**: global class
29+
## secondClass
30+
**Kind**: global class
2931
<a name="new_secondClass_new"></a>
3032

31-
### new secondClass()secondClass
33+
### new secondClass()
34+
secondClass
3235

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

35-
## thirdClass**Kind**: global class
38+
## thirdClass
39+
**Kind**: global class
3640
<a name="new_thirdClass_new"></a>
3741

38-
### new thirdClass()thirdClass
42+
### new thirdClass()
43+
thirdClass
3944

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

42-
## fourthClass**Kind**: global class
47+
## fourthClass
48+
**Kind**: global class
4349
<a name="new_fourthClass_new"></a>
4450

45-
### new fourthClass()fourthClass (no class annotation)
51+
### new fourthClass()
52+
fourthClass (no class annotation)
4653

example/documentation/code/class.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ test: test class
77

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

10-
## Test**Kind**: global class
10+
## Test
11+
**Kind**: global class
1112

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

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

24-
### new Test()This is a test class
25+
### new Test()
26+
This is a test class
2527

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

28-
### test.nameSet current name
30+
### test.name
31+
Set current name
2932

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

33-
### test.nameGet current name
36+
### test.name
37+
Get current name
3438

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

38-
### test.generateFullName() ⇒Generate a fullname
42+
### test.generateFullName() ->
43+
Generate a fullname
3944

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

44-
### Test.Test**Kind**: static class of [<code>Test</code>](#Test)
49+
### Test.Test
50+
**Kind**: static class of [<code>Test</code>](#Test)
4551
<a name="new_Test.Test_new"></a>
4652

47-
#### new Test([name])Creates an instance of Test.
53+
#### new Test([name])
54+
Creates an instance of Test.
4855

4956

5057
| Param | Type | Default |

example/documentation/code/lib/dmd-options.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ title: dmd-options
66

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

9-
## DmdOptions**Kind**: global class
9+
## DmdOptions
10+
**Kind**: global class

example/documentation/code/lib/jsdoc-to-markdown.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ title: jsdoc-to-markdown
66

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

9-
## jsdoc-to-markdown**Example**
9+
## jsdoc-to-markdown
10+
**Example**
1011
```js
1112
const jsdoc2md = require('jsdoc-to-markdown')
1213
```
@@ -26,10 +27,12 @@ const jsdoc2md = require('jsdoc-to-markdown')
2627

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

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

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

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

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

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

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

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

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

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

92-
#### 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.
97+
#### jsdoc2md.clear() -> <code>Promise</code>
98+
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.
9399

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

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

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

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

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

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

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

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

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

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

138148
**Kind**: instance method of [<code>JsdocToMarkdown</code>](#exp_module_jsdoc-to-markdown--JsdocToMarkdown)
139149
**Category**: sync

example/documentation/code/methods.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: A normal ES6 Method
2+
title: A normal ES6 Methodf jdhsfkj dsfhdskjf dksjfhdks j
33
headline: Custom Title!
44
---
55

@@ -8,23 +8,28 @@ headline: Custom Title!
88
## Functions
99

1010
<dl>
11-
<dt><a href="#ES6Method">ES6Method()</a> </dt>
11+
<dt><a href="#ES6Method">ES6Method(param)</a> -> <code>string</code></dt>
1212
<dd><p>A normal ES6 Method</p>
1313
</dd>
14-
<dt><a href="#standardMethod">standardMethod()</a> </dt>
14+
<dt><a href="#standardMethod">standardMethod()</a> -> <code>string</code></dt>
1515
<dd><p>A normal standard Method</p>
1616
</dd>
1717
</dl>
1818

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

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

2324
**Kind**: global function
24-
**Returns**: a String
25+
26+
| Param | Type |
27+
| --- | --- |
28+
| param | <code>string</code> |
29+
2530
<a name="standardMethod"></a>
2631

27-
## standardMethod() ⇒A normal standard Method
32+
## standardMethod() -> <code>string</code>
33+
A normal standard Method
2834

2935
**Kind**: global function
30-
**Returns**: a String

example/documentation/code/objects.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ title: objects
66

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

9-
## objObject description
9+
## obj
10+
Object description
1011

1112
**Kind**: global constant
1213

@@ -17,12 +18,14 @@ title: objects
1718

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

20-
### obj.namename
21+
### obj.name
22+
name
2123

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

25-
### obj.objMethod(parameter) ⇒A function with a parameter and returns the name
27+
### obj.objMethod(parameter) ->
28+
A function with a parameter and returns the name
2629

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

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

36-
### obj.objMethodTwo()Old way to write methods in objects
39+
### obj.objMethodTwo()
40+
Old way to write methods in objects
3741

3842
**Kind**: static method of [<code>obj</code>](#obj)

example/documentation/code/subfolder/subfolder.1/variables.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ title: variables
2222

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

25-
## normalLetVariableA normal let variable
25+
## normalLetVariable
26+
A normal let variable
2627

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

30-
## MY\_CONST\_VARSymbol constant
31+
## MY\_CONST\_VAR
32+
Symbol constant
3133

3234
**Kind**: global constant

example/documentation/code/subfolder/variables.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ title: variables
2222

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

25-
## normalLetVariableA normal let variable
25+
## normalLetVariable
26+
A normal let variable
2627

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

30-
## SUBFOLDERA constant
31+
## SUBFOLDER
32+
A constant
3133

3234
**Kind**: global constant

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"docs": "../bin/vuepress-jsdoc.js --source=./src --dist=./documentation --title=API --exclude=*.test.js",
7+
"docs": "../bin/vuepress-jsdoc.js --source=./src --dist=./documentation --title=API --exclude=*.test.js --partials=./partials/*.hbs",
88
"dev": "vuepress dev documentation",
99
"build": "vuepress build documentation"
1010
},

example/partials/sig-link-html.hbs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{#if name}}{{#sig no-gfm=true ~}}
2+
{{{@depOpen}~}}
3+
<a href="#{{{anchorName}}}">
4+
{{~{@codeOpen}~}}
5+
{{#if @prefix}}{{@prefix}} {{/if~}}
6+
{{@accessSymbol}}{{#if (isEvent)}}"{{{name}}}"{{else}}{{{name}}}{{/if~}}
7+
{{~#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}}
8+
{{{@codeClose}~}}
9+
</a>
10+
{{~#if @returnSymbol}} -> {{/if~}}
11+
{{#if @returnTypes}} {{>linked-type-list types=@returnTypes html=true delimiter=" | " }}{{/if~}}
12+
{{#if @suffix}} {{@suffix}}{{/if~}}
13+
{{{@depClose}~}}
14+
{{~/sig}}{{/if~}}

example/partials/sig-name.hbs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}}
2+
{{#if name}}{{#sig~}}
3+
{{{@depOpen}~}}
4+
{{{@codeOpen}~}}
5+
{{#if @prefix}}{{@prefix}} {{/if~}}
6+
{{@parent~}}
7+
{{@accessSymbol}}{{#if (isEvent)}}"{{{name}}}"{{else}}{{{escape name}}}{{/if~}}
8+
{{#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}}
9+
{{{@codeClose}~}}
10+
{{#if @returnSymbol}} -> {{/if~}}
11+
{{#if @returnTypes}} {{>linked-type-list types=@returnTypes delimiter=" \| " }}{{/if~}}
12+
{{#if @suffix}} {{@suffix}}{{/if~}}
13+
{{{@depClose}~}}
14+
{{~/sig}}{{/if~}}
15+
{{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}}

0 commit comments

Comments
 (0)