diff --git a/.github/workflows/docs-test.yml b/.github/workflows/docs-test.yml index af8b354bbb..55efa57d9e 100644 --- a/.github/workflows/docs-test.yml +++ b/.github/workflows/docs-test.yml @@ -31,3 +31,6 @@ jobs: - name: Check Build run: npm run build working-directory: ./docs + - name: Check Format + run: npm run check-format + working-directory: ./docs diff --git a/docs/.prettierrc b/docs/.prettierrc index 1b5bd8dd9b..b52d8ff57d 100644 --- a/docs/.prettierrc +++ b/docs/.prettierrc @@ -13,6 +13,12 @@ "options": { "parser": "astro" } + }, + { + "files": ["*.md", "*.mdx"], + "options": { + "tabWidth": 2 + } } ] } diff --git a/docs/README.md b/docs/README.md index d1cd65ae3a..274e8d9f61 100644 --- a/docs/README.md +++ b/docs/README.md @@ -34,6 +34,8 @@ All commands are run from the root of the project, from a terminal: | :------------------------ | :----------------------------------------------- | | `npm install` | Installs dependencies | | `npm run dev` | Starts local dev server at `localhost:4321` | +| `npm run format` | Formats your code using Prettier | +| `npm run check-format` | Checks if your code is formatted correctly | | `npm run build` | Build your production site to `./dist/` | | `npm run preview` | Preview your build locally, before deploying | | `npm run astro ...` | Run CLI commands like `astro add`, `astro check` | diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 8fa96e2d97..6f4a237083 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -70,8 +70,8 @@ export default defineConfig({ items: [ 'for-administrators/pipeline-concept', 'for-administrators/existing-preprocessing-pipelines', - 'for-administrators/build-new-preprocessing-pipeline' - ] + 'for-administrators/build-new-preprocessing-pipeline', + ], }, { label: 'Data use terms', link: '/for-administrators/data-use-terms/' }, { label: 'User administration', link: '/for-administrators/user-administration/' }, diff --git a/docs/package.json b/docs/package.json index 0f7b081ef0..781ad76aa1 100644 --- a/docs/package.json +++ b/docs/package.json @@ -9,7 +9,8 @@ "build": "astro check && astro build", "preview": "astro preview", "astro": "astro", - "format": "prettier --ignore-path \"../.gitignore\" --write \"./**/*.{ts,tsx,json,astro,md,mdx,mjs,cjs}\"" + "check-format": "prettier --ignore-path \"../.gitignore\" --ignore-path .gitignore --check \"./**/*.{ts,tsx,json,astro,md,mdx,mjs,cjs}\"", + "format": "prettier --ignore-path \"../.gitignore\" --ignore-path .gitignore --write \"./**/*.{ts,tsx,json,astro,md,mdx,mjs,cjs}\"" }, "dependencies": { "@astrojs/check": "^0.9.4", diff --git a/docs/src/components/MarkdownRenderer.astro b/docs/src/components/MarkdownRenderer.astro index b408a4451a..3adcce4f41 100644 --- a/docs/src/components/MarkdownRenderer.astro +++ b/docs/src/components/MarkdownRenderer.astro @@ -9,10 +9,7 @@ import rehypeStringify from 'rehype-stringify'; const { content } = Astro.props; -const html = String(await unified() - .use(remarkParse) - .use(remarkRehype) - .use(rehypeStringify) - .process(content)); +const html = String(await unified().use(remarkParse).use(remarkRehype).use(rehypeStringify).process(content)); --- -
+ + diff --git a/docs/src/components/SchemaDocs.astro b/docs/src/components/SchemaDocs.astro index f9b2bfac9a..340cf17845 100644 --- a/docs/src/components/SchemaDocs.astro +++ b/docs/src/components/SchemaDocs.astro @@ -4,7 +4,12 @@ * Properties in the schema can be assigned to groups by adding a new "groups": ["group1", "group2"] key to them. * This way, you can split schema definition into semantic groups. */ -import { type JSONSchema7, type JSONSchema7Definition, type JSONSchema7TypeName, type JSONSchema7Type } from 'json-schema'; +import { + type JSONSchema7, + type JSONSchema7Definition, + type JSONSchema7TypeName, + type JSONSchema7Type, +} from 'json-schema'; import MarkdownRenderer from './MarkdownRenderer.astro'; import rawSchema from '../values.schema.json'; @@ -26,24 +31,24 @@ function capitalizeFirst(str: string) { */ function typeToString( type: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined, - enumvals: JSONSchema7Type[] | undefined + enumvals: JSONSchema7Type[] | undefined, ) { - if (type === undefined) return ""; + if (type === undefined) return ''; if (Array.isArray(type)) { - return type.map(t => capitalizeFirst(String(t))).join(", ") + return type.map((t) => capitalizeFirst(String(t))).join(', '); } - if (type === "string" && enumvals !== undefined) { - return enumvals?.map(enumval => String(enumval)).join(", ") + if (type === 'string' && enumvals !== undefined) { + return enumvals?.map((enumval) => String(enumval)).join(', '); } return capitalizeFirst(String(type)); } /** A row in the table. */ interface Row { - key: string, - type?: string, - default?: string, - description?: string + key: string; + type?: string; + default?: string; + description?: string; } const rows: Row[] = []; @@ -55,44 +60,40 @@ const rows: Row[] = []; * @param definition The definition of the property currently observed. */ function addSelfAndChildren(prefix: string, key: string, definition: JSONSchema7Definition) { - if ( - typeof definition === 'object' && - definition !== null - ) { + if (typeof definition === 'object' && definition !== null) { if ('placeholder' in definition) { key = `<${definition.placeholder}>`; } if ('docsIncludePrefix' in definition && definition.docsIncludePrefix === false) { - prefix = ""; + prefix = ''; } - if ( - 'groups' in definition && - Array.isArray(definition.groups) && - definition.groups.includes(group) - ) { - var def = definition.default !== undefined ? String(definition.default) : ""; - if (definition.type === "string" && def !== "") { - def = `"${def}"` + if ('groups' in definition && Array.isArray(definition.groups) && definition.groups.includes(group)) { + var def = definition.default !== undefined ? String(definition.default) : ''; + if (definition.type === 'string' && def !== '') { + def = `"${def}"`; } rows.push({ key: `${prefix}${key}`, type: typeToString(definition.type, definition.enum), default: def, - description: definition.description - }) + description: definition.description, + }); } if ('properties' in definition && definition.properties) { Object.entries(definition.properties).forEach(([k, d]) => addSelfAndChildren(`${prefix}${key}.`, k, d)); } if ('patternProperties' in definition && definition.patternProperties) { - Object.entries(definition.patternProperties).forEach(([k, d]) => addSelfAndChildren(`${prefix}${key}.`, k, d)); + Object.entries(definition.patternProperties).forEach(([k, d]) => + addSelfAndChildren(`${prefix}${key}.`, k, d), + ); } if ('items' in definition && definition.items !== undefined && typeof definition.items === 'object') { const items = definition.items; - if ('length' in items) { // filter out arrays + if ('length' in items) { + // filter out arrays return; } - addSelfAndChildren(`${prefix}${key}.`, "[]", items) + addSelfAndChildren(`${prefix}${key}.`, '[]', items); } } } @@ -101,7 +102,7 @@ if (schema.definitions) { Object.entries(schema.definitions).forEach(([_, definition]) => { if (typeof definition === 'object' && definition.properties) { Object.entries(definition.properties).forEach(([key, definition]) => { - addSelfAndChildren("", key, definition); + addSelfAndChildren('', key, definition); }); } }); @@ -110,10 +111,9 @@ if (schema.definitions) { // start of recursing with the top level properties in the schema. if (schema.properties) { Object.entries(schema.properties).forEach(([key, definition]) => { - addSelfAndChildren("", key, definition); + addSelfAndChildren('', key, definition); }); } - ---{row.key}
{row.key}
+