Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

299 improve schema reference #370

Merged
merged 28 commits into from
Apr 26, 2023
Merged

Conversation

duncandewhurst
Copy link
Contributor

@duncandewhurst duncandewhurst commented Nov 11, 2022

TO-DO:

  • manage.py
    • Fix lint errors
    • Handle nested properties in reference lists and in collapse parameter of jsonschema directives
    • Handle cases where examples of the Value definition don't appear in example.json because they don't make sense in the context of the example:
      • forecasts/0/observations/0/value
      • metrics/0/observations/0/value
      • contractingProcesses/0/summary/modifications/0/oldContractValue
      • contractingProcesses/0/summary/modifications/0/newContractValue
  • Add an introductory paragraph to explain what a sub-schema is
  • Review manually authored text in docs/reference/schema.md to reduce repetition and to identify text that should be added to field descriptions
  • Review text in docs/guidance/example.md to identify text that should be moved to docs/reference/schema.md or to field descriptions
  • Consider removing the worked example in favour of the examples in docs/reference/schema.md
  • Update PR template (added in Add pull request template #374) per Add pull request template #374 (comment)

@duncandewhurst
Copy link
Contributor Author

@jpmckinney please could you check that you're happy with the direction of this PR?

I reused a script that I developed for another project to generate an improved schema reference page. You can preview it here: https://standard.open-contracting.org/staging/infrastructure/299-improve-schema-reference/en/reference/schema/. The main changes are to:

  • Replace 'components' terminology with 'sub-schema' as suggested in Eliminate language of "building blocks" standard#1347
  • Reduce reference table length by collapsing all fields that reference a sub-schema
  • Add the definition/description of each sub-schema
  • Add a list of links to the fields that reference each sub-schema
  • Add an example for each sub-schema

The script can be run as part of pre-commit to keep the schema reference documentation up to date with changes to the schema. It will preserve any manually authored content at the top of the page and under the heading for each sub-schema.

@duncandewhurst
Copy link
Contributor Author

@jpmckinney please could you check that you're happy with the direction of this PR?

@jpmckinney just checking that you saw this request - thanks!

@duncandewhurst duncandewhurst mentioned this pull request Nov 21, 2022
8 tasks
Copy link
Member

@jpmckinney jpmckinney left a comment

Choose a reason for hiding this comment

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

I ran the command, and each time it keeps adding more content...

Edit: Fixed locally.

manage.py Outdated
# Add description
definition["content"].extend([
f"`{defn}` is defined as:\n\n",
"```{jsoninclude-quote} ../../schema/project-level/project-schema.json\n",
Copy link
Member

Choose a reason for hiding this comment

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

sphinxcontrib-opencontracting already had https://sphinxcontrib-opencontracting.readthedocs.io/en/latest/#field-description before this was added to sphinxcontrib-opendataservices.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh! Which would you prefer to use?

Copy link
Member

Choose a reason for hiding this comment

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

I missed this earlier comment - I prefer field-description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in e65bbf5

manage.py Outdated Show resolved Hide resolved
@jpmckinney
Copy link
Member

jpmckinney commented Dec 1, 2022

@jpmckinney
Copy link
Member

jpmckinney commented Dec 1, 2022

The command is failing because these don't exist

  • /projects/0/forecasts/0/observations/0/value
  • /projects/0/metrics/0/observations/0/value
  • /projects/0/contractingProcesses/0/summary/modifications/0/oldContractValue (needs to be index 2)
  • /projects/0/contractingProcesses/0/summary/modifications/0/newContractValue (needs to be index 2)

@jpmckinney
Copy link
Member

I got make to run.

  • I added empty value to forecasts and metrics for now.
  • schema.md needs to be hand-edited to correct the indices for oldContractValue and newContractValue.

Note this diff after running pre-commit:

--- a/docs/_static/i18n.csv
+++ b/docs/_static/i18n.csv
@@ -14,7 +14,7 @@ sector,Project sector,False,
 purpose,Project purpose,True,
 additionalClassifications,Additional classifications,False,
 additionalClassifications,Classification,False,
-additionalClassifications/scheme,Scheme,True,
+additionalClassifications/scheme,Scheme,False,
 additionalClassifications/id,ID,True,
 additionalClassifications/description,Description,True,
 additionalClassifications/uri,URI,False,

@jpmckinney
Copy link
Member

I think we can extract the "this is referenced by" logic to a directive in sphinxcontrib-opencontracting, as suggested in open-contracting/standard#1075 (comment)

Otherwise, I think the rest of the logic can't be generalized, as it's mostly code to add directives in a way that's fairly specific to this project (e.g. other projects might prefer a different order or set of directives).

@jpmckinney
Copy link
Member

jpmckinney commented Dec 1, 2022

This might be for a follow-up PR, but I think it'd be nicer to put definitions on separate pages, as suggested in open-contracting/standard#1075 (comment)

@duncandewhurst
Copy link
Contributor Author

Thanks for the feedback! I take the detailed review to mean that you are happy with the direction of the PR so I will work on your comments and the checklist in the PR description.

@jpmckinney
Copy link
Member

Yup! Direction is good.

@duncandewhurst
Copy link
Contributor Author

duncandewhurst commented Dec 1, 2022

Should we use https://sphinx-design.readthedocs.io/en/rtd-theme/tabs.html instead?

@jpmckinney
Copy link
Member

Ah, yes, even better.

@duncandewhurst
Copy link
Contributor Author

Noting that I've enabled the colon_fence syntax extension as recommended in https://sphinx-design.readthedocs.io/en/rtd-theme/get_started.html. However, that does now mean there's a mix of colon fences and backtick fences.

@duncandewhurst
Copy link
Contributor Author

I think we can extract the "this is referenced by" logic to a directive in sphinxcontrib-opencontracting, as suggested in open-contracting/standard#1075 (comment)

@jpmckinney do you want to do that before this PR is merged or are you happy for it to live here for now?

@jpmckinney
Copy link
Member

Noting that I've enabled the colon_fence syntax extension as recommended

This is mainly recommended so that Markdown syntax highlighters will highlight the Markdown inside the fence (when using backticks, it highlights the whole thing as if it were a code block).

If we don't need that highlighting, it'd be simpler to not enable the extension.

@jpmckinney do you want to do that before this PR is merged or are you happy for it to live here for now?

We can just create/update issues to do it later.

@duncandewhurst
Copy link
Contributor Author

duncandewhurst commented Mar 21, 2023

  • Review text in docs/guidance/example.md to identify text that should be moved to docs/reference/schema.md or to field descriptions
  • Consider removing the worked example in favour of the examples in docs/reference/schema.md

@jpmckinney having reviewed the content of docs/guidance/example.md, it largely repeats content that is already available in either the schema reference page or in the worked example file itself. Now that the examples are integrated into the schema reference documentation, I think that we should reduce repetition by:

  1. Moving the content from https://standard.open-contracting.org/staging/infrastructure/299-improve-schema-reference/en/guidance/example/#overview to the project section of the schema reference page
  2. Removing the content from https://standard.open-contracting.org/staging/infrastructure/299-improve-schema-reference/en/guidance/example/#sections onwards
  3. Updating the remaining content as follows:
    • Expand the narrative summary in the second sentence to describe more of the key features of the worked example file, e.g. the nature of the contracting processes, the variations between the budget and completion values etc.
    • Link to the schema reference page as the place to view the examples in context of the structure of the schema

Does that sound good?

@jpmckinney
Copy link
Member

I'm having trouble visualizing what the new example.md page will look like, since if Overview is moved and Sections is removed, I'm not sure what content is left to update – is it just the content at the start of the page?

@duncandewhurst
Copy link
Contributor Author

I was thinking that it would still be useful for the worked example to have a separate page from the schema reference, which could just be the content that appears before the overview heading with the updates suggested above:

image

@jpmckinney
Copy link
Member

Aha, okay - sounds fine to me!

@duncandewhurst
Copy link
Contributor Author

@jpmckinney this is now ready for review with the exception of the build errors, which relate to the links below. Any idea how to get these to work?

* [`forecasts`](../reference/schema.md#project-schema.json,,forecasts) and [`metrics`](../reference/schema.md#project-schema.json,,metrics) that describe planned and actual physical progress
* [`modifications`](../reference/schema.md#project-schema.json,,metrics) that describe changes to the duration, scope and value of contracting processes
* [`completion`](../reference/schema.md#project-schema.json,,completion) data, describing the final end date, value and scope of the project.

I ended up restructuring the worked example page a little so that is better set up for us to add other examples in the future. Happy to hear your feedback!

@duncandewhurst duncandewhurst marked this pull request as ready for review March 23, 2023 03:02
Copy link
Member

@jpmckinney jpmckinney left a comment

Choose a reason for hiding this comment

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

I committed the fix for the links (drop the part before project-schema.json).

I made a few comments, but haven't read the bulk of the changes (i.e. example.md, schema.md, and manage.py).

We're at a retreat next week, so I'll try to get back to this when I return

docs/conf.py Outdated Show resolved Hide resolved
manage.py Outdated
# Add description
definition["content"].extend([
f"`{defn}` is defined as:\n\n",
"```{jsoninclude-quote} ../../schema/project-level/project-schema.json\n",
Copy link
Member

Choose a reason for hiding this comment

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

I missed this earlier comment - I prefer field-description.

@duncandewhurst
Copy link
Contributor Author

Thanks! I've made those updates.

@duncandewhurst
Copy link
Contributor Author

@jpmckinney just checking if you would have a chance to complete your review over the next week or two? Thanks!

@jpmckinney
Copy link
Member

In the next week or two, yes!

Copy link
Member

@jpmckinney jpmckinney left a comment

Choose a reason for hiding this comment

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

I'll commit my Python documentation change. I haven't reviewed the code, but I figure it works, and we'll probably change it if needed when we cover open-contracting/sphinxcontrib-opencontracting#33

manage.py Outdated Show resolved Hide resolved
@jpmckinney jpmckinney merged commit f520f8b into 0.9-dev Apr 26, 2023
@jpmckinney jpmckinney deleted the 299-improve-schema-reference branch April 26, 2023 01:25
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.

Move content describing the use of the schema from the worked example to the schema reference
2 participants