Skip to content

Commit

Permalink
Some cleanup and documenting
Browse files Browse the repository at this point in the history
  • Loading branch information
fhennig committed Feb 7, 2025
1 parent 65c01e6 commit e234cfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

#
# this file is only copied over from /kubernetes/loculus
src/values.schema.json

# environment variables
Expand Down
20 changes: 6 additions & 14 deletions docs/src/components/SchemaDocs.astro
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
---
/**
* Render parts of a JSON schema into a table.
* specify the schema file in `schemaPath`, and give a `group` to render.
* Render parts of the JSON schema into a table, given a `group` to render.
* 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 { readFile } from 'node:fs/promises';
import { type JSONSchema7, type JSONSchema7Definition, type JSONSchema7TypeName, type JSONSchema7Type } from 'json-schema';
import MarkdownRenderer from './MarkdownRenderer.astro';
import rawSchema from '../values.schema.json';
const { group, fieldColumnClass } = Astro.props;
let schema: JSONSchema7 = {};
// the 'as any' isn't pretty but needed because our schema doesn't actually conform to the type.
// it's still nice to use the type to get at least some type hinting when developing.
let schema: JSONSchema7 = rawSchema as any;
// TODO - schema currently needs to be read like this and cannot be imported,
// because it actually doesn't conform to the JSONSchema7 type.
try {
const data = await readFile('src/values.schema.json', 'utf-8');
schema = JSON.parse(data);
} catch (error) {
console.error('Error reading schema:', error);
}
const { group, fieldColumnClass } = Astro.props;
/** Example: 'boolean' -> 'Boolean'. */
function capitalizeFirst(str: string) {
Expand Down

0 comments on commit e234cfb

Please sign in to comment.