chore(core): add map.json jsonschema (#12701)

This commit is contained in:
Benjamin Cabanes 2022-10-18 15:30:15 -07:00 committed by GitHub
parent e8359d1d0d
commit 6520905fc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1699 additions and 1619 deletions

File diff suppressed because it is too large Load Diff

View File

@ -24,10 +24,10 @@ export const packagesApi = new PackagesApi({
export const nxDocumentsApi = new DocumentsApi({
publicDocsRoot: 'nx-dev/nx-dev/public/documentation',
documentSources: [
documents.find(
documents.content.find(
(x) => x.id === 'nx-documentation'
) as Partial<DocumentMetadata>,
documents.find(
documents.content.find(
(x) => x.id === 'additional-api-references'
) as Partial<DocumentMetadata>,
]
@ -37,15 +37,15 @@ export const nxDocumentsApi = new DocumentsApi({
});
export const nxRecipesApi = new DocumentsApi({
publicDocsRoot: 'nx-dev/nx-dev/public/documentation',
documentSources: [documents.find((x) => x.id === 'nx-recipes')].filter(
(x) => !!x
) as DocumentMetadata[],
documentSources: [
documents.content.find((x) => x.id === 'nx-recipes'),
].filter((x) => !!x) as DocumentMetadata[],
addAncestor: { id: 'recipes', name: 'Recipes' },
});
export const nxCloudDocumentsApi = new DocumentsApi({
publicDocsRoot: 'nx-dev/nx-dev/public/documentation',
documentSources: [
documents.find(
documents.content.find(
(x) => x.id === 'nx-cloud-documentation'
) as Partial<DocumentMetadata>,
]

View File

@ -37,7 +37,7 @@ function filePathExtractor(file: any): string[] {
const mapPathList: string[] = readJsonSync(`${basePath}/map.json`, {
encoding: 'utf8',
})
.map((file: any) => filePathExtractor(file))
.content.map((file: any) => filePathExtractor(file))
.flat();
const readmeMissList = readmePathList.filter((x) => !mapPathList.includes(x));
const mapMissList = mapPathList.filter((x) => !readmePathList.includes(x));

View File

@ -0,0 +1,67 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "documentation-map-schema",
"title": "JSON schema for documentation map",
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Title of the document"
},
"description": {
"type": "string",
"description": "Description of the document"
},
"content": {
"type": "array",
"description": "Dictionary map section",
"items": {
"$ref": "#/definitions/entry"
}
}
},
"definitions": {
"entry": {
"type": "object",
"required": ["name", "id"],
"properties": {
"name": {
"type": "string",
"description": "Name for the current item"
},
"id": {
"type": "string",
"description": "Identifier for the current item"
},
"description": {
"type": "string",
"description": "Description for the item"
},
"file": {
"type": "string",
"description": "Path to the markdown file"
},
"tags": {
"type": "array",
"description": "Tags are used on nx.dev to link related piece of content together (e.g: Related Documentation)"
},
"path": {
"type": "string",
"description": "Custom path or URL to find the item on nx.dev"
},
"isExternal": {
"type": "boolean",
"description": "Is the path provided is external to nx.dev?"
},
"itemList": {
"type": "array",
"description": "Children for the item",
"items": {
"$ref": "#/definitions/entry"
}
}
},
"additionalProperties": false
}
}
}

View File

@ -2,7 +2,7 @@ import { Canvas, Image, SKRSContext2D } from '@napi-rs/canvas';
import { ensureDir, readFile, readJSONSync, writeFileSync } from 'fs-extra';
import { resolve } from 'path';
const mapJson = readJSONSync('./docs/map.json', 'utf8');
const mapJson = readJSONSync('./docs/map.json', 'utf8').content;
const documents: any[] = [
...mapJson.find((x) => x.id === 'nx-documentation')?.['itemList'],

View File

@ -85,7 +85,7 @@ export function getPackageMetadataList(
/**
* Get all the custom overview information on each package if available
*/
const additionalApiReferences: any = DocumentationMap.find(
const additionalApiReferences: any = DocumentationMap.content.find(
(data) => data.id === 'additional-api-references'
).itemList;