@docfy/ember 0.6.0 → 0.7.0
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/docs/components/docfy-output-demo/edit-page.md +32 -0
- package/lib/index.js +9 -0
- package/package.json +4 -4
- package/src/index.ts +21 -1
|
@@ -20,3 +20,35 @@ repository URL as well as the branch to edit.
|
|
|
20
20
|
{{/if}}
|
|
21
21
|
</DocfyOutput>
|
|
22
22
|
```
|
|
23
|
+
|
|
24
|
+
For this to work, you need to include `repository` in your docfy-config:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
// in your docfy-config.js
|
|
28
|
+
module.exports = {
|
|
29
|
+
repository: {
|
|
30
|
+
url: 'https://github.com/@username/repo-name',
|
|
31
|
+
editBranch: 'main',
|
|
32
|
+
},
|
|
33
|
+
...// rest of your config
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## Enterprise (aka on premise) git services
|
|
39
|
+
|
|
40
|
+
`page.editUrl` works for Github, Bitbucket, Gitlab and Sourcehut.
|
|
41
|
+
|
|
42
|
+
For on-premise instances git solutions (i.e. on-premise Gitlab, or on-premise Bitbucket), we expose the `page.relativePath` so that you might construct your own custom editUrl:
|
|
43
|
+
|
|
44
|
+
```hbs
|
|
45
|
+
<DocfyOutput @fromCurrentURL={{true}} as |page|>
|
|
46
|
+
{{#if page.relativePath}}
|
|
47
|
+
<a href=(concat "http://some-enterpise.com/browse/" page.relativePath)
|
|
48
|
+
Click here to edit this page
|
|
49
|
+
</a>
|
|
50
|
+
{{/if}}
|
|
51
|
+
</DocfyOutput>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Note: the edit url for your on-premise instance might be more complex than the example above. But the `page.relativePath` will give you the relative path to that file in your repo.
|
package/lib/index.js
CHANGED
|
@@ -63,12 +63,16 @@ class DocfyBroccoli extends broccoli_plugin_1.default {
|
|
|
63
63
|
debug('Config: ', this.config);
|
|
64
64
|
const docfy = new core_1.default(this.config);
|
|
65
65
|
const result = yield docfy.run(this.config.sources);
|
|
66
|
+
const snippets = {
|
|
67
|
+
components: {}
|
|
68
|
+
};
|
|
66
69
|
result.content.forEach((page) => {
|
|
67
70
|
const parts = [this.outputPath, 'templates', page.meta.url];
|
|
68
71
|
if (page.meta.url[page.meta.url.length - 1] === '/') {
|
|
69
72
|
parts.push('index');
|
|
70
73
|
}
|
|
71
74
|
const fileName = `${path_1.default.join(...parts)}.hbs`;
|
|
75
|
+
// console.log(fileName, "RENDERED AS", page.rendered);
|
|
72
76
|
ensureDirectoryExistence(fileName);
|
|
73
77
|
fs_1.default.writeFileSync(fileName, page.rendered);
|
|
74
78
|
const demoComponents = page.pluginData.demoComponents;
|
|
@@ -77,11 +81,13 @@ class DocfyBroccoli extends broccoli_plugin_1.default {
|
|
|
77
81
|
component.chunks.forEach((chunk) => {
|
|
78
82
|
const chunkPath = path_1.default.join(this.outputPath, 'components', `${component.name.dashCase}.${chunk.ext}`);
|
|
79
83
|
ensureDirectoryExistence(chunkPath);
|
|
84
|
+
snippets.components[`${component.name.dashCase}`] = Object.assign(Object.assign({}, (snippets.components[`${component.name.dashCase}`] || {})), { [chunk.ext]: chunk.code });
|
|
80
85
|
fs_1.default.writeFileSync(chunkPath, chunk.code);
|
|
81
86
|
});
|
|
82
87
|
if (!hasBackingJS(component.chunks)) {
|
|
83
88
|
const chunkPath = path_1.default.join(this.outputPath, 'components', `${component.name.dashCase}.js`);
|
|
84
89
|
ensureDirectoryExistence(chunkPath);
|
|
90
|
+
snippets.components[`${component.name.dashCase}`] = Object.assign(Object.assign({}, (snippets.components[`${component.name.dashCase}`] || {})), { js: templateOnlyComponent });
|
|
85
91
|
fs_1.default.writeFileSync(chunkPath, templateOnlyComponent);
|
|
86
92
|
}
|
|
87
93
|
});
|
|
@@ -91,6 +97,9 @@ class DocfyBroccoli extends broccoli_plugin_1.default {
|
|
|
91
97
|
const urlsJsonFile = path_1.default.join(this.outputPath, 'public', 'docfy-urls.json');
|
|
92
98
|
ensureDirectoryExistence(urlsJsonFile);
|
|
93
99
|
fs_1.default.writeFileSync(urlsJsonFile, JSON.stringify(result.content.map((page) => page.meta.url)));
|
|
100
|
+
const snippetsJsonFile = path_1.default.join(this.outputPath, 'public', 'docfy-snippets.json');
|
|
101
|
+
ensureDirectoryExistence(snippetsJsonFile);
|
|
102
|
+
fs_1.default.writeFileSync(snippetsJsonFile, JSON.stringify(snippets));
|
|
94
103
|
result.staticAssets.forEach((asset) => {
|
|
95
104
|
const dest = path_1.default.join(this.outputPath, 'public', asset.toPath);
|
|
96
105
|
ensureDirectoryExistence(dest);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docfy/ember",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
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.
|
|
33
|
+
"@docfy/core": "^0.7.0",
|
|
34
34
|
"broccoli-bridge": "^1.0.0",
|
|
35
35
|
"broccoli-file-creator": "^2.1.1",
|
|
36
36
|
"broccoli-funnel": "^3.0.8",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@babel/helper-define-map": "^7.16.7",
|
|
55
|
-
"@docfy/plugin-with-prose": "^0.
|
|
55
|
+
"@docfy/plugin-with-prose": "^0.7.0",
|
|
56
56
|
"@ember/optional-features": "^2.0.0",
|
|
57
57
|
"@ember/test-helpers": "^2.6.0",
|
|
58
58
|
"@embroider/compat": "^1.0.0",
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"prember"
|
|
136
136
|
]
|
|
137
137
|
},
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "d24cfd0a838a890c850d0030ec30856d0608267c"
|
|
139
139
|
}
|
package/src/index.ts
CHANGED
|
@@ -60,7 +60,9 @@ class DocfyBroccoli extends Plugin {
|
|
|
60
60
|
debug('Config: ', this.config);
|
|
61
61
|
const docfy = new Docfy(this.config);
|
|
62
62
|
const result = await docfy.run(this.config.sources as SourceConfig[]);
|
|
63
|
-
|
|
63
|
+
const snippets = {
|
|
64
|
+
components: {}
|
|
65
|
+
};
|
|
64
66
|
result.content.forEach((page) => {
|
|
65
67
|
const parts = [this.outputPath, 'templates', page.meta.url];
|
|
66
68
|
|
|
@@ -70,6 +72,7 @@ class DocfyBroccoli extends Plugin {
|
|
|
70
72
|
|
|
71
73
|
const fileName = `${path.join(...parts)}.hbs`;
|
|
72
74
|
|
|
75
|
+
// console.log(fileName, "RENDERED AS", page.rendered);
|
|
73
76
|
ensureDirectoryExistence(fileName);
|
|
74
77
|
fs.writeFileSync(fileName, page.rendered);
|
|
75
78
|
|
|
@@ -83,6 +86,11 @@ class DocfyBroccoli extends Plugin {
|
|
|
83
86
|
`${component.name.dashCase}.${chunk.ext}`
|
|
84
87
|
);
|
|
85
88
|
ensureDirectoryExistence(chunkPath);
|
|
89
|
+
|
|
90
|
+
snippets.components[`${component.name.dashCase}`] = {
|
|
91
|
+
...(snippets.components[`${component.name.dashCase}`] || {}),
|
|
92
|
+
[chunk.ext]: chunk.code
|
|
93
|
+
};
|
|
86
94
|
fs.writeFileSync(chunkPath, chunk.code);
|
|
87
95
|
});
|
|
88
96
|
|
|
@@ -93,6 +101,10 @@ class DocfyBroccoli extends Plugin {
|
|
|
93
101
|
`${component.name.dashCase}.js`
|
|
94
102
|
);
|
|
95
103
|
ensureDirectoryExistence(chunkPath);
|
|
104
|
+
snippets.components[`${component.name.dashCase}`] = {
|
|
105
|
+
...(snippets.components[`${component.name.dashCase}`] || {}),
|
|
106
|
+
js: templateOnlyComponent
|
|
107
|
+
};
|
|
96
108
|
fs.writeFileSync(chunkPath, templateOnlyComponent);
|
|
97
109
|
}
|
|
98
110
|
});
|
|
@@ -109,11 +121,19 @@ class DocfyBroccoli extends Plugin {
|
|
|
109
121
|
'public',
|
|
110
122
|
'docfy-urls.json'
|
|
111
123
|
);
|
|
124
|
+
|
|
112
125
|
ensureDirectoryExistence(urlsJsonFile);
|
|
113
126
|
fs.writeFileSync(
|
|
114
127
|
urlsJsonFile,
|
|
115
128
|
JSON.stringify(result.content.map((page) => page.meta.url))
|
|
116
129
|
);
|
|
130
|
+
const snippetsJsonFile = path.join(
|
|
131
|
+
this.outputPath,
|
|
132
|
+
'public',
|
|
133
|
+
'docfy-snippets.json'
|
|
134
|
+
);
|
|
135
|
+
ensureDirectoryExistence(snippetsJsonFile);
|
|
136
|
+
fs.writeFileSync(snippetsJsonFile, JSON.stringify(snippets));
|
|
117
137
|
result.staticAssets.forEach((asset) => {
|
|
118
138
|
const dest = path.join(this.outputPath, 'public', asset.toPath);
|
|
119
139
|
ensureDirectoryExistence(dest);
|