Skip to content

Commit db3ec62

Browse files
committed
feat(nxdoc): include getting started text
1 parent b0bf601 commit db3ec62

File tree

12 files changed

+174
-20
lines changed

12 files changed

+174
-20
lines changed

docs/core/executors/test.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# @nx-dotnet/core:test
22

3-
## Runs test via the dotnet cli
3+
## NxDotnet Test Executor
4+
5+
Runs test via the dotnet cli
46

57
## Options
68

docs/core/index.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,48 @@ slug: /core/
66

77
# Getting Started
88

9+
## Prerequisites
10+
11+
- Have an existing nx workspace. For creating this, see [nrwl's documentation](https://nx.dev/latest/angular/getting-started/nx-setup).
12+
- .NET SDK is installed, and `dotnet` is available on the path. For help on this, see [Microsoft's documentation](https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install)
13+
14+
## Installation
15+
16+
### NPM
17+
18+
```shell
19+
npm i --save-dev @nx-dotnet/core
20+
npx nx g @nx-dotnet/core:init
21+
```
22+
23+
### PNPM
24+
25+
```shell
26+
pnpm i --save-dev @nx-dotnet/core
27+
pnpx nx g @nx-dotnet/core:init
28+
```
29+
30+
### Yarn
31+
32+
```shell
33+
yarn add --dev @nx-dotnet/core
34+
npx nx g @nx-dotnet/core:init
35+
```
36+
37+
## Generate and run your first api!
38+
39+
Generate my-api, and my-api-test with C# and nunit tests.
40+
41+
```shell
42+
npx nx g @nx-dotnet/core:app my-api --test-template nunit --language C#
43+
```
44+
45+
Run my-api locally
46+
47+
```shell
48+
npx nx serve my-api
49+
```
50+
951
# API Reference
1052

1153
## Generators

docs/nxdoc/generators/generate-docs.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,16 @@
44

55
### outputDirectory (string)
66

7+
Where should the generated docs be placed?
8+
9+
### gettingStartedFile (string)
10+
11+
File contents to place before the API reference section for each package. <src> is replaced by the package's root.
12+
713
### skipFrontMatter (boolean)
14+
15+
Nxdoc generates frontmatter suitable for docusaurus by default.
16+
17+
### skipFormat (boolean)
18+
19+
Skips running the output through prettier

docs/nxdoc/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ slug: /nxdoc/
66

77
# Getting Started
88

9+
# nxdoc
10+
11+
This library was generated with [Nx](https://nx.dev).
12+
13+
## Running unit tests
14+
15+
Run `nx test nxdoc` to execute the unit tests via [Jest](https://jestjs.io).
16+
917
# API Reference
1018

1119
## Generators

docs/typescript/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@ slug: /typescript/
66

77
# Getting Started
88

9+
# typescript
10+
11+
This library was generated with [Nx](https://nx.dev).
12+
13+
## Running unit tests
14+
15+
Run `nx test typescript` to execute the unit tests via [Jest](https://jestjs.io).
16+
917
# API Reference

packages/core/README.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,41 @@
1-
# nx-dotnet
1+
## Prerequisites
22

3-
This library was generated with [Nx](https://nx.dev).
3+
- Have an existing nx workspace. For creating this, see [nrwl's documentation](https://nx.dev/latest/angular/getting-started/nx-setup).
4+
- .NET SDK is installed, and `dotnet` is available on the path. For help on this, see [Microsoft's documentation](https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install)
45

5-
## Running unit tests
6+
## Installation
67

7-
Run `nx test nx-dotnet` to execute the unit tests via [Jest](https://jestjs.io).
8+
### NPM
9+
10+
```shell
11+
npm i --save-dev @nx-dotnet/core
12+
npx nx g @nx-dotnet/core:init
13+
```
14+
15+
### PNPM
16+
17+
```shell
18+
pnpm i --save-dev @nx-dotnet/core
19+
pnpx nx g @nx-dotnet/core:init
20+
```
21+
22+
### Yarn
23+
24+
```shell
25+
yarn add --dev @nx-dotnet/core
26+
npx nx g @nx-dotnet/core:init
27+
```
28+
29+
## Generate and run your first api!
30+
31+
Generate my-api, and my-api-test with C# and nunit tests.
32+
33+
```shell
34+
npx nx g @nx-dotnet/core:app my-api --test-template nunit --language C#
35+
```
36+
37+
Run my-api locally
38+
39+
```shell
40+
npx nx serve my-api
41+
```

packages/core/src/executors/test/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"$schema": "http://json-schema.org/schema",
33
"cli": "nx",
4-
"title": "Runs test via the dotnet cli",
5-
"description": "",
4+
"title": "NxDotnet Test Executor",
5+
"description": "Runs test via the dotnet cli",
66
"type": "object",
77
"properties": {
88
"testAdapterPath": {

packages/nxdoc/src/generators/generate-docs/generator.ts

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import {
2-
Tree,
3-
getProjects,
4-
ProjectConfiguration,
2+
formatFiles,
53
generateFiles,
4+
getProjects,
65
names,
6+
ProjectConfiguration,
77
readJson,
8-
formatFiles,
8+
Tree,
99
} from '@nrwl/devkit';
1010

11+
import { readFileSync } from 'fs';
1112
import * as path from 'path';
13+
1214
import { Schema } from './schema';
1315
import {
1416
ExecutorsCollection,
@@ -19,9 +21,20 @@ import {
1921
export default async function (host: Tree, options: Schema) {
2022
const projects = await findProjectsWithGeneratorsOrExecutors(host);
2123

22-
const packageDetails: {packageName: string, projectFileName: string, project: Omit<ProjectConfiguration, 'generators'>, generators: number, executors: number}[] = [];
24+
const packageDetails: {
25+
packageName: string;
26+
projectFileName: string;
27+
project: Omit<ProjectConfiguration, 'generators'>;
28+
generators: number;
29+
executors: number;
30+
}[] = [];
2331

2432
projects.forEach((project) => {
33+
const gettingStartedFile = options.gettingStartedFile.replace(
34+
'<src>',
35+
project.root,
36+
);
37+
2538
const generators = project.generators
2639
? readJson<GeneratorsCollection>(host, `${project.root}/generators.json`)
2740
.generators
@@ -34,7 +47,13 @@ export default async function (host: Tree, options: Schema) {
3447
const packageName = readJson(host, `${project.root}/package.json`).name;
3548
const projectFileName = names(project.name).fileName;
3649

37-
packageDetails.push({packageName, projectFileName, project, generators: Object.keys(generators).length, executors: Object.keys(executors).length})
50+
packageDetails.push({
51+
packageName,
52+
projectFileName,
53+
project,
54+
generators: Object.keys(generators).length,
55+
executors: Object.keys(executors).length,
56+
});
3857

3958
generateFiles(
4059
host,
@@ -47,6 +66,9 @@ export default async function (host: Tree, options: Schema) {
4766
generators,
4867
executors,
4968
underscore: '_',
69+
gettingStartedMd: options.gettingStartedFile
70+
? readFileSync(gettingStartedFile).toString()
71+
: '',
5072
frontMatter: options.skipFrontMatter
5173
? null
5274
: {
@@ -99,12 +121,19 @@ export default async function (host: Tree, options: Schema) {
99121
});
100122
});
101123

102-
generateFiles(host, path.join(__dirname, 'templates/root'), options.outputDirectory, ({
103-
packageDetails,
104-
includeFrontMatter: !options.skipFrontMatter
105-
}))
124+
generateFiles(
125+
host,
126+
path.join(__dirname, 'templates/root'),
127+
options.outputDirectory,
128+
{
129+
packageDetails,
130+
includeFrontMatter: !options.skipFrontMatter,
131+
},
132+
);
106133

107-
formatFiles(host);
134+
if (!options.skipFormat) {
135+
formatFiles(host);
136+
}
108137
}
109138

110139
export async function findProjectsWithGeneratorsOrExecutors(host: Tree) {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export interface Schema {
22
outputDirectory: string;
33
skipFrontMatter: boolean;
4+
skipFormat: boolean;
5+
gettingStartedFile: string;
46
}

packages/nxdoc/src/generators/generate-docs/schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@
55
"properties": {
66
"outputDirectory": {
77
"type": "string",
8+
"description": "Where should the generated docs be placed?",
89
"default": "docs"
910
},
11+
"gettingStartedFile": {
12+
"type": "string",
13+
"description": "File contents to place before the API reference section for each package. <src> is replaced by the package's root.",
14+
"default": "<src>/readme.md"
15+
},
1016
"skipFrontMatter": {
1117
"type": "boolean",
18+
"description": "Nxdoc generates frontmatter suitable for docusaurus by default.",
19+
"default": false
20+
},
21+
"skipFormat": {
22+
"type": "boolean",
23+
"description": "Skips running the output through prettier",
1224
"default": false
1325
}
1426
},

0 commit comments

Comments
 (0)