docs(docs): writting docs

This commit is contained in:
thomas
2023-09-25 17:37:48 +02:00
parent 0d4348c46b
commit fac946ff6a
47 changed files with 89 additions and 77 deletions

View File

@@ -1,9 +1,9 @@
{
"generators": {
"app": {
"factory": "./src/generators/app/generator",
"schema": "./src/generators/app/schema.json",
"description": "app generator"
"challenge": {
"factory": "./src/generators/challenge/generator",
"schema": "./src/generators/challenge/schema.json",
"description": "challenge generator"
},
"readme": {
"factory": "./src/generators/readme/generator",

View File

@@ -1,10 +1,12 @@
---
title: <%= difficulty %> <%= title %>
description: Challenge <%= challengeNumber %> is about ...
sidebar:
order: <%= challengeNumber %>
---
:::note
WIP
WIP: The following documentation need to be written.
:::
<div class="chip">Challenge #<%= challengeNumber %></div>

View File

@@ -12,12 +12,12 @@ import {
updateJson,
} from '@nx/devkit';
import { Linter } from '@nx/linter';
import { readFile, writeFile } from 'fs';
import { readFile, writeFile } from 'fs/promises';
import { join } from 'path';
import { getProjectDir } from '../../utils/normalize';
import { Schema } from './schema';
export async function appGenerator(tree: Tree, options: Schema) {
export async function challengeGenerator(tree: Tree, options: Schema) {
const { appDirectory } = getProjectDir(options.name, options.directory);
const challengeNumberPath = 'challenge-number.json';
@@ -70,38 +70,24 @@ export async function appGenerator(tree: Tree, options: Schema) {
});
}
readFile('./README.md', 'utf-8', function (err, contents) {
const regex = new RegExp(`all ${challengeNumber} challenges`);
const replaced = contents.replace(
regex,
`all ${challengeNumber + 1} challenges`
);
const readme = await readFile('./README.md', { encoding: 'utf-8' });
writeFile('./README.md', replaced, 'utf-8', function (err) {
console.log(err);
});
const readmeRegex = new RegExp(`all ${challengeNumber} challenges`);
const readmeReplace = readme.replace(
readmeRegex,
`all ${challengeNumber + 1} challenges`
);
await writeFile('./README.md', readmeReplace, 'utf-8');
const docs = await readFile('./docs/src/content/docs/index.mdx', {
encoding: 'utf-8',
});
readFile(
'./docs/src/content/docs/index.mdx',
'utf-8',
function (err, contents) {
const regex = new RegExp(`${challengeNumber} Challenges`, 'gi');
const replaced = contents.replace(
regex,
`${challengeNumber + 1} Challenges`
);
const regex = new RegExp(`${challengeNumber} Challenges`, 'gi');
const replaced = docs.replace(regex, `${challengeNumber + 1} Challenges`);
writeFile(
'./docs/src/content/docs/index.mdx',
replaced,
'utf-8',
function (err) {
console.log(err);
}
);
}
);
await writeFile('./docs/src/content/docs/index.mdx', replaced, 'utf-8');
updateJson(tree, challengeNumberPath, (json) => {
json.total = json.total + 1;
@@ -111,4 +97,4 @@ export async function appGenerator(tree: Tree, options: Schema) {
await formatFiles(tree);
}
export default appGenerator;
export default challengeGenerator;

View File

@@ -1,13 +1,13 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "GeneratorNxApp",
"title": "Creates an Angular application.",
"description": "Creates an Angular application.",
"$id": "GeneratorNxChallenge",
"title": "Creates the setup for a new Angular Challenge.",
"description": "Creates the boilerplate for an Angular Challenge.",
"type": "object",
"cli": "nx",
"properties": {
"name": {
"description": "The name of the application. (should be in camel case)",
"description": "The name of the application. (should be in kebab case)",
"type": "string",
"$default": {
"$source": "argv",
@@ -19,6 +19,7 @@
"title": {
"description": "Title of your challenge. (use quote to add spaces)",
"type": "string",
"maxLength": "25",
"$default": {
"$source": "argv",
"index": 1