@docfy/ember 0.6.0 → 0.8.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/.docfy-config.js CHANGED
@@ -20,7 +20,7 @@ module.exports = {
20
20
  ]
21
21
  ],
22
22
  plugins: [docfyWithProse],
23
- rehypePlugins: [prism],
23
+ rehypePlugins: [() => [prism, { alias: { gts: 'ts', gjs: 'js' } }]],
24
24
  sources: [
25
25
  {
26
26
  root: path.join(__dirname, 'dummy-docs'),
@@ -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.
@@ -0,0 +1,20 @@
1
+ ---
2
+ category: ember
3
+ ---
4
+
5
+ # Preview works with gts, gjs
6
+
7
+ This works
8
+
9
+ ```gts preview
10
+ import Component from '@glimmer/component';
11
+
12
+ // components/hello.gjs
13
+ export default class Hello extends Component {
14
+ isThisCool = true;
15
+
16
+ <template>
17
+ Is This Cool?: {{this.isThisCool}}
18
+ </template>
19
+ }
20
+ ```
package/lib/index.js CHANGED
@@ -42,7 +42,7 @@ function ensureDirectoryExistence(filePath) {
42
42
  function hasBackingJS(chunks) {
43
43
  for (let i = 0; i < chunks.length; i++) {
44
44
  const chunk = chunks[i];
45
- if (chunk.ext === 'js' || chunk.ext === 'ts') {
45
+ if (['js', 'ts', 'gts', 'gjs'].includes(chunk.ext)) {
46
46
  return true;
47
47
  }
48
48
  }
@@ -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);
@@ -13,7 +13,7 @@ exports.default = (0, plugin_1.default)({
13
13
  ctx.pages.forEach((page) => {
14
14
  const demoComponents = [];
15
15
  (0, unist_util_visit_1.default)(page.ast, 'code', (node) => {
16
- if (['preview-template'].includes(node.meta || '')) {
16
+ if (['preview-template', 'preview'].includes(node.meta || '')) {
17
17
  demoComponents.push({
18
18
  name: (0, utils_1.generateDemoComponentName)(`docfy-demo-preview-${path_1.default.basename(page.meta.url)}`, seenNames),
19
19
  chunks: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docfy/ember",
3
- "version": "0.6.0",
3
+ "version": "0.8.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.6.0",
33
+ "@docfy/core": "^0.8.0",
34
34
  "broccoli-bridge": "^1.0.0",
35
35
  "broccoli-file-creator": "^2.1.1",
36
36
  "broccoli-funnel": "^3.0.8",
@@ -40,8 +40,8 @@
40
40
  "broccoli-source": "^3.0.1",
41
41
  "calculate-cache-key-for-tree": "2.0.0",
42
42
  "debug": "^4.3.3",
43
- "ember-cli-babel": "^7.26.11",
44
- "ember-cli-htmlbars": "^6.0.1",
43
+ "ember-cli-babel": "^8.2.0",
44
+ "ember-cli-htmlbars": "^6.3.0",
45
45
  "ember-cli-typescript": "^4.2.1",
46
46
  "ember-get-config": "^1.0.2",
47
47
  "mdast-util-to-string": "^2.0.0",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "@babel/helper-define-map": "^7.16.7",
55
- "@docfy/plugin-with-prose": "^0.6.0",
55
+ "@docfy/plugin-with-prose": "^0.8.0",
56
56
  "@ember/optional-features": "^2.0.0",
57
57
  "@ember/test-helpers": "^2.6.0",
58
58
  "@embroider/compat": "^1.0.0",
@@ -85,6 +85,7 @@
85
85
  "broccoli-asset-rev": "^3.0.0",
86
86
  "ember-auto-import": "^2.4.0",
87
87
  "ember-cli": "~4.1.1",
88
+ "ember-cli-babel": "8.2.0",
88
89
  "ember-cli-dependency-checker": "^3.2.0",
89
90
  "ember-cli-fastboot": "^3.2.0-beta.5",
90
91
  "ember-cli-fastboot-testing": "^0.6.0",
@@ -103,6 +104,7 @@
103
104
  "ember-sinon": "^5.0.0",
104
105
  "ember-source": "~4.1.0",
105
106
  "ember-source-channel-url": "^3.0.0",
107
+ "ember-template-imports": "^4.0.0",
106
108
  "ember-template-lint": "^2.18.0",
107
109
  "ember-try": "^2.0.0",
108
110
  "loader.js": "^4.7.0",
@@ -135,5 +137,5 @@
135
137
  "prember"
136
138
  ]
137
139
  },
138
- "gitHead": "3745bd3c8c45202a0c11d8fd502b52a5e3f62493"
140
+ "gitHead": "c9d70834e458a98818858fb59244a459f60475d1"
139
141
  }
package/src/index.ts CHANGED
@@ -35,7 +35,7 @@ function hasBackingJS(chunks: DemoComponentChunk[]): boolean {
35
35
  for (let i = 0; i < chunks.length; i++) {
36
36
  const chunk = chunks[i];
37
37
 
38
- if (chunk.ext === 'js' || chunk.ext === 'ts') {
38
+ if (['js', 'ts', 'gts', 'gjs'].includes(chunk.ext)) {
39
39
  return true;
40
40
  }
41
41
  }
@@ -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);
@@ -18,7 +18,7 @@ export default plugin({
18
18
  const demoComponents: DemoComponent[] = [];
19
19
 
20
20
  visit(page.ast, 'code', (node: CodeNode) => {
21
- if (['preview-template'].includes(node.meta || '')) {
21
+ if (['preview-template', 'preview'].includes(node.meta || '')) {
22
22
  demoComponents.push({
23
23
  name: generateDemoComponentName(
24
24
  `docfy-demo-preview-${path.basename(page.meta.url)}`,