Skip to content

Generate schema Markdown docs automatically in this repository#94

Open
neilmb wants to merge 4 commits intomainfrom
nmb/generate-docs
Open

Generate schema Markdown docs automatically in this repository#94
neilmb wants to merge 4 commits intomainfrom
nmb/generate-docs

Conversation

@neilmb
Copy link
Collaborator

@neilmb neilmb commented Mar 20, 2026

We want to be able to generate documentation automatically that matches the schema we have defined. This is a proof-of-concept that uses a Python library called json-schema-for-humans that can create documentation from the schema files. We use a custom script to handle our multi-file setup and to make the process repeatable for use in CI/CD.

This is a first attempt. The generated markdown is correct and accurate, but not as user-friendly as it could be. The json-schema-for-humans library has numerous customization options and we can even use our own templates entirely as we work to improve the documentation and make it more and more useful for implementers. I anticipate lots of ongoing work to identify issues with the documentation and make incremental improvements.

Typically, we wouldn't include generated files in a Github repository alongside the "source" which in this case are the schema files, but in order to have the documentation close at hand, we are going to do so here. To ensure that the generated documentation doesn't get out of date with the schema as we've defined it, we use a Github Actions job to run our script in --check mode where it tests whether the docs it would generate agree with what is in the repository.

Copy link
Collaborator

@jbrown-xentity jbrown-xentity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some general comments, not required to be solved.
We should consider where and how it looks to "release" these as official documents, maybe on resources.data.gov? Or maybe we don't need to release all of them, we just release catalog and dataset (since the sub-fields are documented)?

Comment on lines +27 to +29
- name: Check docs are up-to-date
working-directory: ./jsonschema
run: poetry run python generate_schema_docs.py --check
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't there tools for committing back to the branch for things like this? Could we just run the generate and push back, instead of running the --check?

Comment on lines +75 to +107
### <a name="restrictionStatus_oneOf_i0"></a>Property `AccessRestriction > restrictionStatus > oneOf > Concept`

**Title:** Concept

| | |
| ------------------------- | ---------------------------------- |
| **Type** | `object` |
| **Required** | No |
| **Additional properties** | Any type allowed |
| **Defined in** | /dcat-us/3.0.0/definitions/concept |

**Description:** inline description of restriction status

| Property | Type | Title/Description |
| ------------------------------------------------------------- | -------------- | ------------------------------------------------------------------------------------ |
| - [@id](#restrictionStatus_oneOf_i0_@id ) | string | - |
| - [@type](#restrictionStatus_oneOf_i0_@type ) | string | - |
| - [altLabel](#restrictionStatus_oneOf_i0_altLabel ) | null or string | alternate label |
| - [altLabelMap](#restrictionStatus_oneOf_i0_altLabelMap ) | null or object | Language map for alternate label. E.g. {'es': 'spanish words', 'fr': 'french words'} |
| - [definition](#restrictionStatus_oneOf_i0_definition ) | null or string | definition |
| - [definitionMap](#restrictionStatus_oneOf_i0_definitionMap ) | null or object | Language map for definition. E.g. {'es': 'spanish words', 'fr': 'french words'} |
| + [inScheme](#restrictionStatus_oneOf_i0_inScheme ) | Combination | in scheme |
| - [notation](#restrictionStatus_oneOf_i0_notation ) | Combination | notation |
| + [prefLabel](#restrictionStatus_oneOf_i0_prefLabel ) | string | preferred label |
| - [prefLabelMap](#restrictionStatus_oneOf_i0_prefLabelMap ) | null or object | Language map for preferred label. E.g. {'es': 'spanish words', 'fr': 'french words'} |

#### <a name="restrictionStatus_oneOf_i0_@id"></a>Property `AccessRestriction > restrictionStatus > oneOf > Concept > @id`

| | |
| ------------ | -------- |
| **Type** | `string` |
| **Required** | No |
| **Format** | `iri` |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are going to get extremely repetitive. In the options, can we link to the class reference instead of inline displaying the options for the class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants