@docfy/ember 0.4.3 → 0.4.7

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 CHANGED
@@ -4,9 +4,9 @@ Ember integration with Docfy.
4
4
 
5
5
  ## Compatibility
6
6
 
7
- * Ember.js v3.16 or above
8
- * Ember CLI v2.13 or above
9
- * Node.js v10 or above
7
+ - Ember.js v3.16 or above
8
+ - Ember CLI v2.13 or above
9
+ - Node.js v10 or above
10
10
 
11
11
  ## Installation
12
12
 
@@ -20,10 +20,25 @@ export default class DocfyService extends Service {
20
20
  return this.findByUrl(this.router.currentURL);
21
21
  }
22
22
 
23
- findNestedChildrenByName(name: string): NestedPageMetadata | undefined {
24
- return this.nested.children.find((item) => {
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: 3
3
3
  ---
4
+
4
5
  # Edit this page
5
6
 
6
7
  This is another example using `@fromCurrentURL`, but here we build a "edit this
@@ -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">
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  order: 1
3
3
  ---
4
+
4
5
  # Sidebar Navigation
5
6
 
6
7
  In this example, we are filtering the `NestedPageMetadata` by the scope name `docs`.
@@ -42,4 +43,3 @@ more deep into the tree or more shadow.
42
43
  </ul>
43
44
  </DocfyOutput>
44
45
  ```
45
-
@@ -8,7 +8,6 @@ Here is another example that builds a top nav that could be used for the entire
8
8
  application. It will link to any top-level pages as well as to the first page of
9
9
  every child.
10
10
 
11
-
12
11
  ```hbs template
13
12
  <DocfyOutput @type="nested" as |node|>
14
13
  <ul>
@@ -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 | Description | Type | Default Value |
20
- |----------------|--------------------------------|-------------------------|---------------|
21
- | `@scope` | Filter links by a scope name | `string` \| `undefined` | |
19
+ | Argument | Description | Type | Default Value |
20
+ | -------- | ---------------------------- | ----------------------- | ------------- |
21
+ | `@scope` | Filter links by a scope name | `string` \| `undefined` | |
@@ -1,6 +1,7 @@
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
@@ -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
 
@@ -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.
@@ -13,6 +13,6 @@ This is my Demo: <DocfyLink @to={{this.url}}>My Link</DocfyLink>
13
13
  import Component from '@glimmer/component';
14
14
 
15
15
  export default class MyDemo extends Component {
16
- url = '/docs'
16
+ url = '/docs';
17
17
  }
18
18
  ```
@@ -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
- ~~~md
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
 
@@ -5,11 +5,14 @@ This project is on GitHub.
5
5
  ![GitHub](./github-icon.png)
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
- __This is bold text__
29
+ **This is bold text**
28
30
 
29
- *This is italic text*
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
- >> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
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
- + Create a list by starting a line with `+`, `-`, or `*`
58
- + Sub-lists are made by indenting 2 spaces:
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
- * Ac tristique libero volutpat at
61
- + Facilisis in pretium nisl aliquet
60
+ - Ac tristique libero volutpat at
61
+ * Facilisis in pretium nisl aliquet
62
62
  - Nulla volutpat aliquam velit
63
- + Very easy!
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
- 1. You can use sequential numbers...
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
- ``` js
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 | Description |
120
- | ------:| -----------:|
121
- | data | path to data files to supply the data that will be passed into templates. |
122
- | engine | engine to be used for processing templates. Handlebars is the default. |
123
- | ext | extension to be used for dest files. |
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/ "title text!")
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
  ![Minion](https://octodex.github.com/images/minion.png)
@@ -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 "The Dojocat"
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
- 3. Recipit precor in opus quam Philyreia potest
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.
@@ -21,6 +21,6 @@ This is a cool feature.
21
21
  import Component from '@glimmer/component';
22
22
 
23
23
  export default class MyDemo extends Component {
24
- url = '/docs/ember/'
24
+ url = '/docs/ember/';
25
25
  }
26
26
  ```
@@ -9,8 +9,7 @@ I can use markdown here.
9
9
  - Item 1
10
10
  - Item 2
11
11
 
12
- *Super Cool*
13
-
12
+ _Super Cool_
14
13
 
15
14
  ```hbs template
16
15
  <DocfyLink @to="/" class="font-bold" data-test-id="demo-2">
@@ -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
@@ -0,0 +1,3 @@
1
+ ```hbs template
2
+ demo for ember folder
3
+ ```
@@ -2,7 +2,6 @@
2
2
 
3
3
  This is a simple markdown
4
4
 
5
-
6
5
  Where are a lot of cool features here. One of them is to preview a template.
7
6
 
8
7
  ```hbs preview-template
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 = `
@@ -108,6 +109,19 @@ module.exports = {
108
109
  }
109
110
  this._super.included.apply(this, args);
110
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
+ var _a, _b, _c;
116
+ switch (treeType) {
117
+ case 'app': {
118
+ const sources = (_c = (_b = (_a = this.docfyConfig) === null || _a === void 0 ? void 0 : _a.sources) === null || _b === void 0 ? void 0 : _b.map((item) => item.root)) === null || _c === void 0 ? void 0 : _c.join(',');
119
+ return calculate_cache_key_for_tree_1.default(treeType, this, [sources]);
120
+ }
121
+ default:
122
+ return calculate_cache_key_for_tree_1.default(treeType, this);
123
+ }
124
+ },
111
125
  treeForApp(tree) {
112
126
  const trees = [this._super.treeForApp.call(this, tree)];
113
127
  if (isDeepAddonInstance(this)) {
@@ -56,7 +56,10 @@ exports.default = plugin_1.default({
56
56
  });
57
57
  }
58
58
  });
59
- const componentName = utils_1.generateDemoComponentName(`docfy-demo-${path_1.default.basename(page.source).split('.')[0]}-${path_1.default.basename(demo.source).split('.')[0]}`, seenNames);
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",
3
+ "version": "0.4.7",
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.2",
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.2",
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": "ee2f6ff6cac7b3c52d7ec8b640b1dba7c18b3ea5"
125
+ "gitHead": "b774d9e5bd1e676ac79dc61c4ef061c380a21b94"
125
126
  }
@@ -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(name: string): NestedPageMetadata | undefined;
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
 
@@ -134,6 +135,21 @@ module.exports = {
134
135
  this._super.included.apply(this, args);
135
136
  },
136
137
 
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
+
137
153
  treeForApp(tree: Node): Node {
138
154
  const trees: Node[] = [this._super.treeForApp.call(this, tree)];
139
155
  if (isDeepAddonInstance(this)) {
@@ -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-${path.basename(page.source).split('.')[0]}-${
80
+ `docfy-demo-${baseName}-${
76
81
  path.basename(demo.source).split('.')[0]
77
82
  }`,
78
83
  seenNames