Skip to content

Commit a7828c5

Browse files
committed
feat(repo): schematic to generate docs #53
1 parent 45567c0 commit a7828c5

File tree

6 files changed

+169
-0
lines changed

6 files changed

+169
-0
lines changed

docs/core/core.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# core
2+
3+
## Generators
4+
5+
### lib
6+
nx-dotnet generator
7+
8+
### app
9+
Generate a new C# project.
10+
11+
### project-reference
12+
Adds a reference from one project to another.
13+
14+
### init
15+
init generator
16+
17+
### sync
18+
sync generator
19+
20+
### nuget-reference
21+
nuget-reference generator
22+
23+
### restore
24+
Restores NuGet packages and .NET tools used by the workspace
25+
26+
27+
## Executors
28+
29+
### build
30+
build executor
31+
32+
### serve
33+
serve executor
34+
35+
### test
36+
test executor
37+
38+
### publish
39+
publish executor
40+
41+
### format
42+
Formats and lints a project using the dotnet-format tool

docs/typescript/typescript.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# typescript
2+
3+
## Generators
4+
5+
### typescript
6+
typescript generator
7+
8+
9+
## Executors
10+
11+
### build
12+
build executor
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import {
2+
Tree,
3+
formatFiles,
4+
installPackagesTask,
5+
getProjects,
6+
ProjectConfiguration,
7+
NxJsonProjectConfiguration,
8+
generateFiles,
9+
names,
10+
readJson,
11+
} from '@nrwl/devkit';
12+
import { libraryGenerator } from '@nrwl/workspace/generators';
13+
import * as path from 'path';
14+
import { ExecutorsCollection, GeneratorsCollection } from './schema-json.interface';
15+
16+
export default async function (host: Tree, schema: any) {
17+
const projects = await findProjectsWithGeneratorsOrExecutors(host);
18+
projects.forEach((p) => {
19+
const generators = readJson<GeneratorsCollection>(host, `${p.root}/generators.json`);
20+
const executors = readJson<ExecutorsCollection>(host, `${p.root}/executors.json`);
21+
generateFiles(host, path.join(__dirname, 'templates'), `docs`, {
22+
projectFileName: names(p.name).fileName,
23+
project: p,
24+
generators: generators.generators,
25+
executors: executors.executors
26+
});
27+
});
28+
}
29+
30+
export async function findProjectsWithGeneratorsOrExecutors(host: Tree) {
31+
const projects: ({
32+
name: string;
33+
generators: boolean;
34+
executors: boolean;
35+
} & Omit<ProjectConfiguration, 'generators'>)[] = [];
36+
getProjects(host).forEach((configuration, project) => {
37+
const res = projectContainsGeneratorsOrExecutors(host, configuration);
38+
if (res) {
39+
projects.push({
40+
...configuration,
41+
name: project,
42+
...res,
43+
});
44+
}
45+
});
46+
return projects;
47+
}
48+
49+
export function projectContainsGeneratorsOrExecutors(
50+
host: Tree,
51+
project: ProjectConfiguration,
52+
): false | { generators: boolean; executors: boolean } {
53+
const executors = host.isFile(`${project.root}/executors.json`);
54+
const generators = host.isFile(`${project.root}/generators.json`);
55+
return !(executors || generators) ? false : { generators, executors };
56+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export interface SchemaJSON {}
2+
3+
export interface GeneratorsCollection {
4+
name: string;
5+
version: string;
6+
generators: {
7+
[key: string]: GeneratorConfiguration
8+
};
9+
}
10+
11+
export interface ExecutorsCollection {
12+
executors: {
13+
[key: string]: ExecutorConfiguration;
14+
};
15+
builders: {
16+
[key: string]: ExecutorConfiguration;
17+
};
18+
}
19+
20+
export interface ExecutorConfiguration {
21+
implementation: string;
22+
schema: string;
23+
description: string;
24+
}
25+
26+
export interface GeneratorConfiguration {
27+
factory: string;
28+
schema: string;
29+
description: string;
30+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"cli": "nx",
3+
"id": "generate-docs",
4+
"type": "object",
5+
"properties": {
6+
// "name": {
7+
// "type": "string",
8+
// "description": "Library name",
9+
// "$default": {
10+
// "$source": "argv",
11+
// "index": 0
12+
// }
13+
// }
14+
}
15+
// "required": ["name"]
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# <%= project.name %>
2+
3+
## Generators
4+
<% Object.entries(generators).forEach(([key, config]) => { %>
5+
### <%= key %>
6+
<%= config.description %>
7+
<% }) %>
8+
9+
## Executors
10+
<% Object.entries(executors).forEach(([key, config]) => { %>
11+
### <%= key %>
12+
<%= config.description %>
13+
<% }) %>

0 commit comments

Comments
 (0)