@docfy/ember 0.4.2 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/addon/services/docfy.ts +17 -2
- package/docs/components/docfy-demo.md +0 -2
- package/docs/components/docfy-link.md +1 -2
- package/docs/components/docfy-output-demo/edit-page.md +1 -0
- package/docs/components/docfy-output-demo/on-this-page.md +1 -1
- package/docs/components/docfy-output-demo/sidebar.md +1 -1
- package/docs/components/docfy-output-demo/top-nav.md +0 -1
- package/docs/components/docfy-output.md +1 -2
- package/docs/components/docfy-previous-and-next-page.md +3 -3
- package/docs/configuration.md +3 -5
- package/docs/index.md +3 -5
- package/docs/writing-demos-demo/demo1.md +1 -1
- package/docs/writing-demos.md +4 -2
- package/dummy-docs/README.md +26 -31
- package/dummy-docs/introduction.md +1 -1
- package/dummy-docs/packages/core/helpers/genereate-flat-output.md +0 -1
- package/dummy-docs/packages/ember/components/docfy-link-demo/demo1.md +1 -1
- package/dummy-docs/packages/ember/components/docfy-link-demo/demo2.md +1 -2
- package/dummy-docs/packages/ember/components/docfy-output.md +0 -1
- package/dummy-docs/packages/ember/demo/my-ember-demo.md +3 -0
- package/dummy-docs/packages/ember/index.md +0 -1
- package/lib/index.js +32 -2
- package/lib/plugins/extract-demos-to-components.js +4 -1
- package/package.json +5 -4
- package/services/docfy.d.ts +1 -1
- package/src/index.ts +41 -8
- package/src/plugins/extract-demos-to-components.ts +6 -1
package/README.md
CHANGED
package/addon/services/docfy.ts
CHANGED
|
@@ -20,10 +20,25 @@ export default class DocfyService extends Service {
|
|
|
20
20
|
return this.findByUrl(this.router.currentURL);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
findNestedChildrenByName(
|
|
24
|
-
|
|
23
|
+
findNestedChildrenByName(
|
|
24
|
+
scope: string,
|
|
25
|
+
previousNested: NestedPageMetadata | undefined | null = null
|
|
26
|
+
): NestedPageMetadata | undefined {
|
|
27
|
+
if (previousNested === null) {
|
|
28
|
+
previousNested = this.nested;
|
|
29
|
+
}
|
|
30
|
+
const parts = scope.split('/');
|
|
31
|
+
const name = parts.shift();
|
|
32
|
+
|
|
33
|
+
const foundScope = previousNested?.children.find((item) => {
|
|
25
34
|
return item.name === name;
|
|
26
35
|
});
|
|
36
|
+
|
|
37
|
+
if (parts.length > 0) {
|
|
38
|
+
return this.findNestedChildrenByName(parts.join('/'), foundScope);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return foundScope;
|
|
27
42
|
}
|
|
28
43
|
|
|
29
44
|
findByUrl(url: string, scopeByNestedName?: string): PageMetadata | undefined {
|
|
@@ -6,7 +6,6 @@ title: <DocfyDemo>
|
|
|
6
6
|
|
|
7
7
|
# {{"<DocfyDemo>"}}
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
This component is used internally to render demos. It's not meant to be used directly,
|
|
11
10
|
although that's possible. The scope of what you want to understand is the CSS
|
|
12
11
|
classes such that you can style the parts of the demo component yourself.
|
|
@@ -16,7 +15,6 @@ Make sure to look at [writing demos](../writing-demos.md), so you can understand
|
|
|
16
15
|
Below is an example of how styling could look like. It uses
|
|
17
16
|
[TailwindCSS](https://tailwindcss.com/) and [PostCSS Nested](https://github.com/postcss/postcss-nested).
|
|
18
17
|
|
|
19
|
-
|
|
20
18
|
```css
|
|
21
19
|
.docfy-demo__example {
|
|
22
20
|
@apply p-4 border rounded-t;
|
|
@@ -19,14 +19,13 @@ Ember doesn't have support for anchors.
|
|
|
19
19
|
> markdown files. It gives a pleasant User Experience because it can use the
|
|
20
20
|
> Ember Routing to make the page transition, removing the need for a full-page reload.
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
Below you can see a simple example of this component; however, you can see more
|
|
24
23
|
of its usage throughout the documentation.
|
|
25
24
|
|
|
26
25
|
# API
|
|
27
26
|
|
|
28
27
|
| Argument | Description | Type | Default Value |
|
|
29
|
-
|
|
28
|
+
| -------------- | ----------------------------------------------- | ----------------------- | ------------- |
|
|
30
29
|
| `@to` | The URL to link | `string` | |
|
|
31
30
|
| `@anchor` | An anchor | `string` \| `undefined` | |
|
|
32
31
|
| `@activeClass` | The classes to be added when the link is active | `string` \| `undefined` | |
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
order: 2
|
|
3
3
|
---
|
|
4
|
+
|
|
4
5
|
# On this page
|
|
5
6
|
|
|
6
7
|
In this example, we are using the option `@fromCurrentURL`. It tells the component
|
|
@@ -11,7 +12,6 @@ can render their child for subheadings and their sub-subheadings. The depth of
|
|
|
11
12
|
headings available here is default to 6 but can be changed using the configuration
|
|
12
13
|
option `tocMaxDepth`.
|
|
13
14
|
|
|
14
|
-
|
|
15
15
|
```hbs template
|
|
16
16
|
<DocfyOutput @fromCurrentURL={{true}} as |page|>
|
|
17
17
|
<div class="mb-4 font-medium">
|
|
@@ -9,7 +9,6 @@ title: <DocfyOutput>
|
|
|
9
9
|
This component exposes some of the result data from the build that you can use
|
|
10
10
|
to render, for example, a sidebar navigation, "on this page" section, and more.
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
Depending on the arguments you pass to the component, the output could be one of
|
|
14
13
|
the following values:
|
|
15
14
|
|
|
@@ -28,7 +27,7 @@ This component has a few different options that are used to filter what the
|
|
|
28
27
|
returning value should be. Here is the arguments this component accepts.
|
|
29
28
|
|
|
30
29
|
| Argument | Description | Type | Default Value |
|
|
31
|
-
|
|
30
|
+
| ----------------- | ----------------------------------------------------- | ------------------------ | ------------- |
|
|
32
31
|
| `@type` | If the result should be a flat list or nested | `'flat'` \| `'nested'` | `'nested'` |
|
|
33
32
|
| `@fromCurrentURL` | If the result should be filtered from the current URL | `boolean` \| `undefined` | |
|
|
34
33
|
| `@url` | Find the page definition for the given URL | `string` \| `undefined` | |
|
|
@@ -16,6 +16,6 @@ would prevent linking to a page in tutorials from a documentation page.
|
|
|
16
16
|
|
|
17
17
|
# API
|
|
18
18
|
|
|
19
|
-
| Argument
|
|
20
|
-
|
|
21
|
-
| `@scope`
|
|
19
|
+
| Argument | Description | Type | Default Value |
|
|
20
|
+
| -------- | ---------------------------- | ----------------------- | ------------- |
|
|
21
|
+
| `@scope` | Filter links by a scope name | `string` \| `undefined` | |
|
package/docs/configuration.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
order: 2
|
|
3
3
|
---
|
|
4
|
+
|
|
4
5
|
# Configuration
|
|
5
6
|
|
|
6
7
|
Docfy has a set of options you can configure and might have read about them
|
|
7
|
-
[here](
|
|
8
|
+
[here](../../../docs/configuration.md). You might have been wondering how
|
|
8
9
|
to set these options in the Ember app context.
|
|
9
10
|
|
|
10
11
|
The Docfy integration with Ember reads a file named `.docfy-config.js` from the
|
|
@@ -24,10 +25,7 @@ const codeImport = require('remark-code-import');
|
|
|
24
25
|
|
|
25
26
|
module.exports = {
|
|
26
27
|
remarkPlugins: [
|
|
27
|
-
[
|
|
28
|
-
autolinkHeadings,
|
|
29
|
-
{ behavior: 'wrap' }
|
|
30
|
-
],
|
|
28
|
+
[autolinkHeadings, { behavior: 'wrap' }],
|
|
31
29
|
codeImport,
|
|
32
30
|
highlight
|
|
33
31
|
],
|
package/docs/index.md
CHANGED
|
@@ -8,7 +8,6 @@ title: Getting Started
|
|
|
8
8
|
Let's get started by creating a new Ember app and adding Docfy to it. For adding
|
|
9
9
|
to existing apps, jump to the step after creating the app.
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
## Generate the App
|
|
13
12
|
|
|
14
13
|
There isn't anything special here; just create the ember app and remove the
|
|
@@ -45,8 +44,8 @@ export default class Router extends EmberRouter {
|
|
|
45
44
|
rootURL = config.rootURL;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
Router.map(function() {
|
|
49
|
-
addDocfyRoutes(this)
|
|
47
|
+
Router.map(function () {
|
|
48
|
+
addDocfyRoutes(this);
|
|
50
49
|
});
|
|
51
50
|
```
|
|
52
51
|
|
|
@@ -103,7 +102,7 @@ for building design systems that use the styles from your design in your docs.
|
|
|
103
102
|
We can add a `docs` template that will be used when rendering any documentation
|
|
104
103
|
page because of Ember's routing and templating patterns.
|
|
105
104
|
|
|
106
|
-
In your `app/templates/docs.hbs` add the
|
|
105
|
+
In your `app/templates/docs.hbs` add the following:
|
|
107
106
|
|
|
108
107
|
```hbs
|
|
109
108
|
<DocfyOutput @scope="docs" as |node|>
|
|
@@ -128,7 +127,6 @@ the simplest navigation component we can build, ignoring any nested sections
|
|
|
128
127
|
you might define. You can learn more about these components and their capabilities
|
|
129
128
|
in their respective documentation page.
|
|
130
129
|
|
|
131
|
-
|
|
132
130
|
## Add Previous and Next Page Links
|
|
133
131
|
|
|
134
132
|
Documentation sites usually have a previous and next page link. Docfy provides a component that gives you the ability to add this feature.
|
package/docs/writing-demos.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
order: 3
|
|
3
3
|
---
|
|
4
|
+
|
|
4
5
|
# Writing Demos
|
|
5
6
|
|
|
6
7
|
Docfy has a concept of "demo" markdown files. It allows you to write code in
|
|
@@ -18,6 +19,7 @@ template only components by only specifying the HBS template.
|
|
|
18
19
|
Below you can see how a demo markdown file looks like.
|
|
19
20
|
|
|
20
21
|
```md file=writing-demos-demo/demo1.md
|
|
22
|
+
|
|
21
23
|
```
|
|
22
24
|
|
|
23
25
|
The demo will be injected into the owner file as a new section called "Examples";
|
|
@@ -44,11 +46,11 @@ users can see the code.
|
|
|
44
46
|
|
|
45
47
|
Below is an example of how it works:
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
````md
|
|
48
50
|
```hbs preview-template
|
|
49
51
|
Click in the link to navigate to the home page: <DocfyLink @to="/">Home</DocfyLink>
|
|
50
52
|
```
|
|
51
|
-
|
|
53
|
+
````
|
|
52
54
|
|
|
53
55
|
And here you can see how it looks like when rendered:
|
|
54
56
|
|
package/dummy-docs/README.md
CHANGED
|
@@ -5,11 +5,14 @@ This project is on GitHub.
|
|
|
5
5
|

|
|
6
6
|
|
|
7
7
|
## h2 Heading
|
|
8
|
+
|
|
8
9
|
### h3 Heading
|
|
10
|
+
|
|
9
11
|
#### h4 Heading
|
|
12
|
+
|
|
10
13
|
##### h5 Heading
|
|
11
|
-
###### h6 Heading
|
|
12
14
|
|
|
15
|
+
###### h6 Heading
|
|
13
16
|
|
|
14
17
|
## Paragraphs
|
|
15
18
|
|
|
@@ -19,20 +22,18 @@ I think I'll use it to format all of my documents from now on.
|
|
|
19
22
|
|
|
20
23
|
"Smartypants, double quotes" and 'single quotes'
|
|
21
24
|
|
|
22
|
-
|
|
23
25
|
## Emphasis
|
|
24
26
|
|
|
25
27
|
**This is bold text**
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
**This is bold text**
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
_This is italic text_
|
|
30
32
|
|
|
31
33
|
_This is italic text_
|
|
32
34
|
|
|
33
35
|
~~Strikethrough~~
|
|
34
36
|
|
|
35
|
-
|
|
36
37
|
## Blockquotes
|
|
37
38
|
|
|
38
39
|
> Dorothy followed her through many of the beautiful rooms in her castle.
|
|
@@ -43,24 +44,23 @@ _This is italic text_
|
|
|
43
44
|
>
|
|
44
45
|
> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
|
|
45
46
|
|
|
46
|
-
|
|
47
47
|
### Nested Blockquotes
|
|
48
48
|
|
|
49
49
|
> Dorothy followed her through many of the beautiful rooms in her castle.
|
|
50
50
|
>
|
|
51
|
-
|
|
51
|
+
> > The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
|
|
52
52
|
|
|
53
53
|
## Lists
|
|
54
54
|
|
|
55
55
|
Unordered
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
- Create a list by starting a line with `+`, `-`, or `*`
|
|
58
|
+
- Sub-lists are made by indenting 2 spaces:
|
|
59
59
|
- Marker character change forces new list start:
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
- Ac tristique libero volutpat at
|
|
61
|
+
* Facilisis in pretium nisl aliquet
|
|
62
62
|
- Nulla volutpat aliquam velit
|
|
63
|
-
|
|
63
|
+
- Very easy!
|
|
64
64
|
|
|
65
65
|
Ordered
|
|
66
66
|
|
|
@@ -68,16 +68,14 @@ Ordered
|
|
|
68
68
|
2. Consectetur adipiscing elit
|
|
69
69
|
3. Integer molestie lorem at massa
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
1. ...or keep all the numbers as `1.`
|
|
71
|
+
4. You can use sequential numbers...
|
|
72
|
+
5. ...or keep all the numbers as `1.`
|
|
74
73
|
|
|
75
74
|
Start numbering with offset:
|
|
76
75
|
|
|
77
76
|
57. foo
|
|
78
77
|
1. bar
|
|
79
78
|
|
|
80
|
-
|
|
81
79
|
## Code
|
|
82
80
|
|
|
83
81
|
Inline `code`
|
|
@@ -89,7 +87,6 @@ Indented code
|
|
|
89
87
|
line 2 of code
|
|
90
88
|
line 3 of code
|
|
91
89
|
|
|
92
|
-
|
|
93
90
|
Block code "fences"
|
|
94
91
|
|
|
95
92
|
```
|
|
@@ -98,7 +95,7 @@ Sample text here...
|
|
|
98
95
|
|
|
99
96
|
Syntax highlighting
|
|
100
97
|
|
|
101
|
-
```
|
|
98
|
+
```js
|
|
102
99
|
var foo = function (bar) {
|
|
103
100
|
return bar++;
|
|
104
101
|
};
|
|
@@ -108,30 +105,28 @@ console.log(foo(5));
|
|
|
108
105
|
|
|
109
106
|
## Tables
|
|
110
107
|
|
|
111
|
-
| Option | Description
|
|
112
|
-
| ------ |
|
|
108
|
+
| Option | Description |
|
|
109
|
+
| ------ | ------------------------------------------------------------------------- |
|
|
113
110
|
| data | path to data files to supply the data that will be passed into templates. |
|
|
114
|
-
| engine | engine to be used for processing templates. Handlebars is the default.
|
|
115
|
-
| ext | extension to be used for dest files.
|
|
111
|
+
| engine | engine to be used for processing templates. Handlebars is the default. |
|
|
112
|
+
| ext | extension to be used for dest files. |
|
|
116
113
|
|
|
117
114
|
Right aligned columns
|
|
118
115
|
|
|
119
|
-
| Option |
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
| engine |
|
|
123
|
-
|
|
|
124
|
-
|
|
116
|
+
| Option | Description |
|
|
117
|
+
| -----: | ------------------------------------------------------------------------: |
|
|
118
|
+
| data | path to data files to supply the data that will be passed into templates. |
|
|
119
|
+
| engine | engine to be used for processing templates. Handlebars is the default. |
|
|
120
|
+
| ext | extension to be used for dest files. |
|
|
125
121
|
|
|
126
122
|
## Links
|
|
127
123
|
|
|
128
124
|
[link text](http://dev.nodeca.com)
|
|
129
125
|
|
|
130
|
-
[link with title](http://nodeca.github.io/pica/demo/
|
|
126
|
+
[link with title](http://nodeca.github.io/pica/demo/ 'title text!')
|
|
131
127
|
|
|
132
128
|
Autoconverted link https://github.com/nodeca/pica (enable linkify to see)
|
|
133
129
|
|
|
134
|
-
|
|
135
130
|
## Images
|
|
136
131
|
|
|
137
132
|

|
|
@@ -142,4 +137,4 @@ Like links, Images also have a footnote style syntax
|
|
|
142
137
|
|
|
143
138
|
With a reference later in the document defining the URL location:
|
|
144
139
|
|
|
145
|
-
[id]: https://octodex.github.com/images/dojocat.jpg
|
|
140
|
+
[id]: https://octodex.github.com/images/dojocat.jpg 'The Dojocat'
|
|
@@ -23,7 +23,7 @@ Byblis vobisque me venerisque possem **una** nihil volui desiderioque quam
|
|
|
23
23
|
parilique quosque victor contingere urbem monendo. Meae est precor moenibus.
|
|
24
24
|
|
|
25
25
|
1. Suis cum ille
|
|
26
|
-
|
|
26
|
+
2. Recipit precor in opus quam Philyreia potest
|
|
27
27
|
|
|
28
28
|
```js
|
|
29
29
|
import Docfy from '@docfy/core';
|
|
@@ -5,7 +5,6 @@ subcategory: helpers
|
|
|
5
5
|
|
|
6
6
|
# genereateFlatOutput
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
Lorem markdownum animaeque obsedit adversam, saevi sed resupina tenuesque levius
|
|
10
9
|
tenenti utque. Cornibus et opes crudelia primus procul alvum exit: dum frondes!
|
|
11
10
|
Cornibus e, putat procul nostro erat cunctantem munus inventus quod.
|
|
@@ -9,7 +9,6 @@ Lorem markdownum animaeque obsedit adversam, saevi sed resupina tenuesque levius
|
|
|
9
9
|
tenenti utque. Cornibus et opes crudelia primus procul alvum exit: dum frondes!
|
|
10
10
|
Cornibus e, putat procul nostro erat cunctantem munus inventus quod.
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
## Example of "On this page"
|
|
14
13
|
|
|
15
14
|
```hbs
|
package/lib/index.js
CHANGED
|
@@ -24,6 +24,7 @@ const core_1 = __importDefault(require("@docfy/core"));
|
|
|
24
24
|
const docfy_output_template_1 = __importDefault(require("./docfy-output-template"));
|
|
25
25
|
const get_config_1 = __importDefault(require("./get-config"));
|
|
26
26
|
const utils_1 = require("./plugins/utils");
|
|
27
|
+
const calculate_cache_key_for_tree_1 = __importDefault(require("calculate-cache-key-for-tree"));
|
|
27
28
|
const debug_1 = __importDefault(require("debug"));
|
|
28
29
|
const debug = debug_1.default('@docfy/ember');
|
|
29
30
|
const templateOnlyComponent = `
|
|
@@ -47,6 +48,10 @@ function hasBackingJS(chunks) {
|
|
|
47
48
|
}
|
|
48
49
|
return false;
|
|
49
50
|
}
|
|
51
|
+
// eslint-disable-next-line
|
|
52
|
+
function isDeepAddonInstance(addon) {
|
|
53
|
+
return addon.parent !== addon.project;
|
|
54
|
+
}
|
|
50
55
|
class DocfyBroccoli extends broccoli_plugin_1.default {
|
|
51
56
|
constructor(inputNodes, options = {}) {
|
|
52
57
|
super(inputNodes, options);
|
|
@@ -98,12 +103,31 @@ module.exports = {
|
|
|
98
103
|
name: require('../package').name,
|
|
99
104
|
docfyConfig: undefined,
|
|
100
105
|
included(...args) {
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
if (!isDeepAddonInstance(this)) {
|
|
107
|
+
this.docfyConfig = get_config_1.default(this.project.root);
|
|
108
|
+
this.bridge = new broccoli_bridge_1.default();
|
|
109
|
+
}
|
|
103
110
|
this._super.included.apply(this, args);
|
|
104
111
|
},
|
|
112
|
+
// Re-enables caching of this addon, due to opting out
|
|
113
|
+
// of the caching implicitly by specifying treeFor* methods
|
|
114
|
+
cacheKeyForTree(treeType) {
|
|
115
|
+
switch (treeType) {
|
|
116
|
+
case 'app': {
|
|
117
|
+
const sources = this.docfyConfig.sources
|
|
118
|
+
.map((item) => item.root)
|
|
119
|
+
.join(',');
|
|
120
|
+
return calculate_cache_key_for_tree_1.default(treeType, this, [sources]);
|
|
121
|
+
}
|
|
122
|
+
default:
|
|
123
|
+
return calculate_cache_key_for_tree_1.default(treeType, this);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
105
126
|
treeForApp(tree) {
|
|
106
127
|
const trees = [this._super.treeForApp.call(this, tree)];
|
|
128
|
+
if (isDeepAddonInstance(this)) {
|
|
129
|
+
return trees[0];
|
|
130
|
+
}
|
|
107
131
|
const inputs = [new broccoli_source_1.UnwatchedDir(this.project.root)];
|
|
108
132
|
this.docfyConfig.sources.forEach((item) => {
|
|
109
133
|
if (item.root && item.root !== this.project.root) {
|
|
@@ -117,12 +141,18 @@ module.exports = {
|
|
|
117
141
|
},
|
|
118
142
|
treeForAddon(tree) {
|
|
119
143
|
const trees = [this._super.treeForAddon.call(this, tree)];
|
|
144
|
+
if (isDeepAddonInstance(this)) {
|
|
145
|
+
return trees[0];
|
|
146
|
+
}
|
|
120
147
|
const EmberApp = require('ember-cli/lib/broccoli/ember-app'); // eslint-disable-line
|
|
121
148
|
const modulePrefix = this.project.config(EmberApp.env()).modulePrefix;
|
|
122
149
|
trees.push(new broccoli_file_creator_1.default('output.js', docfy_output_template_1.default(modulePrefix)));
|
|
123
150
|
return new broccoli_merge_trees_1.default(trees);
|
|
124
151
|
},
|
|
125
152
|
treeForPublic() {
|
|
153
|
+
if (isDeepAddonInstance(this)) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
126
156
|
return new broccoli_funnel_1.default(this.bridge.placeholderFor('docfy-tree'), {
|
|
127
157
|
srcDir: 'public',
|
|
128
158
|
destDir: './'
|
|
@@ -56,7 +56,10 @@ exports.default = plugin_1.default({
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
-
|
|
59
|
+
// 1. exclude extension
|
|
60
|
+
// 2. remove /index.md because of web conventions
|
|
61
|
+
const baseName = page.source.replace('/index.md', '').split('.')[0];
|
|
62
|
+
const componentName = utils_1.generateDemoComponentName(`docfy-demo-${baseName}-${path_1.default.basename(demo.source).split('.')[0]}`, seenNames);
|
|
60
63
|
const demoTitle = unist_util_find_1.default(demo.ast, (node) => node.type === 'heading' && node.depth === 1);
|
|
61
64
|
if (demoTitle) {
|
|
62
65
|
demoTitle.depth = 3;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docfy/ember",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Ember integration with Docfy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test:ember-compatibility": "echo 'ember try:each TODO'"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@docfy/core": "^0.4.
|
|
33
|
+
"@docfy/core": "^0.4.4",
|
|
34
34
|
"broccoli-bridge": "^1.0.0",
|
|
35
35
|
"broccoli-file-creator": "^2.1.1",
|
|
36
36
|
"broccoli-funnel": "^3.0.3",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"broccoli-node-api": "^1.7.0",
|
|
39
39
|
"broccoli-plugin": "^4.0.3",
|
|
40
40
|
"broccoli-source": "^3.0.0",
|
|
41
|
+
"calculate-cache-key-for-tree": "2.0.0",
|
|
41
42
|
"debug": "^4.3.1",
|
|
42
43
|
"ember-cli-babel": "^7.23.1",
|
|
43
44
|
"ember-cli-htmlbars": "^5.3.1",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"unist-util-visit": "^2.0.2"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@docfy/plugin-with-prose": "^0.4.
|
|
54
|
+
"@docfy/plugin-with-prose": "^0.4.4",
|
|
54
55
|
"@ember/optional-features": "^2.0.0",
|
|
55
56
|
"@ember/test-helpers": "^2.1.4",
|
|
56
57
|
"@embroider/compat": "^0.36.0",
|
|
@@ -121,5 +122,5 @@
|
|
|
121
122
|
"prember"
|
|
122
123
|
]
|
|
123
124
|
},
|
|
124
|
-
"gitHead": "
|
|
125
|
+
"gitHead": "e062ebaf86b5508cb2096de069ed054829f58eb9"
|
|
125
126
|
}
|
package/services/docfy.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export default class DocfyService extends Service {
|
|
|
6
6
|
get flat(): PageMetadata[];
|
|
7
7
|
get nested(): NestedPageMetadata;
|
|
8
8
|
get currentPage(): PageMetadata | undefined;
|
|
9
|
-
findNestedChildrenByName(
|
|
9
|
+
findNestedChildrenByName(scope: string, previousNested?: NestedPageMetadata | undefined | null): NestedPageMetadata | undefined;
|
|
10
10
|
findByUrl(url: string, scopeByNestedName?: string): PageMetadata | undefined;
|
|
11
11
|
previousPage(scopeByNestedName?: string): PageMetadata | undefined;
|
|
12
12
|
nextPage(scopeByNestedName?: string): PageMetadata | undefined;
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { DemoComponentChunk } from './plugins/types';
|
|
|
13
13
|
import docfyOutputTemplate from './docfy-output-template';
|
|
14
14
|
import getDocfyConfig from './get-config';
|
|
15
15
|
import { isDemoComponents } from './plugins/utils';
|
|
16
|
+
import cacheKeyForTree from 'calculate-cache-key-for-tree';
|
|
16
17
|
import debugFactory from 'debug';
|
|
17
18
|
const debug = debugFactory('@docfy/ember');
|
|
18
19
|
|
|
@@ -41,6 +42,11 @@ function hasBackingJS(chunks: DemoComponentChunk[]): boolean {
|
|
|
41
42
|
return false;
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
// eslint-disable-next-line
|
|
46
|
+
function isDeepAddonInstance(addon: any): boolean {
|
|
47
|
+
return addon.parent !== addon.project;
|
|
48
|
+
}
|
|
49
|
+
|
|
44
50
|
class DocfyBroccoli extends Plugin {
|
|
45
51
|
config: DocfyConfig;
|
|
46
52
|
|
|
@@ -122,14 +128,33 @@ module.exports = {
|
|
|
122
128
|
docfyConfig: undefined,
|
|
123
129
|
|
|
124
130
|
included(...args: unknown[]): void {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
if (!isDeepAddonInstance(this)) {
|
|
132
|
+
this.docfyConfig = getDocfyConfig(this.project.root);
|
|
133
|
+
this.bridge = new BroccoliBridge();
|
|
134
|
+
}
|
|
128
135
|
this._super.included.apply(this, args);
|
|
129
136
|
},
|
|
130
137
|
|
|
131
|
-
|
|
132
|
-
|
|
138
|
+
// Re-enables caching of this addon, due to opting out
|
|
139
|
+
// of the caching implicitly by specifying treeFor* methods
|
|
140
|
+
cacheKeyForTree(treeType: string): string {
|
|
141
|
+
switch (treeType) {
|
|
142
|
+
case 'app': {
|
|
143
|
+
const sources = (this.docfyConfig as DocfyConfig).sources
|
|
144
|
+
.map((item) => item.root)
|
|
145
|
+
.join(',');
|
|
146
|
+
return cacheKeyForTree(treeType, this, [sources]);
|
|
147
|
+
}
|
|
148
|
+
default:
|
|
149
|
+
return cacheKeyForTree(treeType, this);
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
treeForApp(tree: Node): Node {
|
|
154
|
+
const trees: Node[] = [this._super.treeForApp.call(this, tree)];
|
|
155
|
+
if (isDeepAddonInstance(this)) {
|
|
156
|
+
return trees[0];
|
|
157
|
+
}
|
|
133
158
|
|
|
134
159
|
const inputs: InputNode[] = [new UnwatchedDir(this.project.root)];
|
|
135
160
|
|
|
@@ -147,8 +172,12 @@ module.exports = {
|
|
|
147
172
|
return new MergeTrees(trees, { overwrite: true });
|
|
148
173
|
},
|
|
149
174
|
|
|
150
|
-
treeForAddon(tree:
|
|
151
|
-
const trees:
|
|
175
|
+
treeForAddon(tree: Node): Node {
|
|
176
|
+
const trees: Node[] = [this._super.treeForAddon.call(this, tree)];
|
|
177
|
+
if (isDeepAddonInstance(this)) {
|
|
178
|
+
return trees[0];
|
|
179
|
+
}
|
|
180
|
+
|
|
152
181
|
const EmberApp = require('ember-cli/lib/broccoli/ember-app'); // eslint-disable-line
|
|
153
182
|
const modulePrefix = this.project.config(EmberApp.env()).modulePrefix;
|
|
154
183
|
|
|
@@ -157,7 +186,11 @@ module.exports = {
|
|
|
157
186
|
return new MergeTrees(trees);
|
|
158
187
|
},
|
|
159
188
|
|
|
160
|
-
treeForPublic(): Node {
|
|
189
|
+
treeForPublic(): Node | undefined {
|
|
190
|
+
if (isDeepAddonInstance(this)) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
161
194
|
return new Funnel(
|
|
162
195
|
(this.bridge as BroccoliBridge).placeholderFor('docfy-tree'),
|
|
163
196
|
{
|
|
@@ -71,8 +71,13 @@ export default plugin({
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
|
+
|
|
75
|
+
// 1. exclude extension
|
|
76
|
+
// 2. remove /index.md because of web conventions
|
|
77
|
+
const baseName = page.source.replace('/index.md', '').split('.')[0];
|
|
78
|
+
|
|
74
79
|
const componentName = generateDemoComponentName(
|
|
75
|
-
`docfy-demo-${
|
|
80
|
+
`docfy-demo-${baseName}-${
|
|
76
81
|
path.basename(demo.source).split('.')[0]
|
|
77
82
|
}`,
|
|
78
83
|
seenNames
|