-
Notifications
You must be signed in to change notification settings - Fork 316
Adopt Diataxis #6868
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
Merged
Merged
Adopt Diataxis #6868
Changes from 6 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
4d524c0
Introduce user_manual.
trexfeathers cabd701
Reader-level restructure.
trexfeathers 619827d
Add sphinx-needs to dependencies.
trexfeathers 917139c
Add licence header to user_manual_directives.py.
trexfeathers b85ce62
Merge remote-tracking branch 'upstream/main' into diataxis
trexfeathers 5ab8bfc
Address Sphinx warnings.
trexfeathers 3ca882f
Populate the explanation and how-to directories.
trexfeathers b6123e2
Populate the reference and tutorial directories.
trexfeathers 39526bd
Fix some references I missed before.
trexfeathers 293131f
Refactor of get_started.
trexfeathers 8b3ee35
Remove defunct IEP directory.
trexfeathers 122f4c2
Itemise all of Iris public API.
trexfeathers cbf0630
Rendering improvements.
trexfeathers adf85ca
Itemise all of the Iris docs pages.
trexfeathers c146081
Itemise all of the Gallery pages.
trexfeathers ae8e1d9
Topic descriptions.
trexfeathers fd88e68
user_manual_directives.py code quality.
trexfeathers a7adaa8
Merge remote-tracking branch 'upstream/main' into diataxis
trexfeathers 3e4ac28
Needs item validation routine.
trexfeathers cac5e12
Remove column titles.
trexfeathers 9199a06
Fix doctests.
trexfeathers eddc28b
Merge remote-tracking branch 'upstream/main' into diataxis
trexfeathers bb8cd62
Implement redirects.
trexfeathers 6f79242
Merge remote-tracking branch 'upstream/main' into diataxis
trexfeathers 6909483
Update lock files.
trexfeathers e40df15
Better use of inbuilt indenting.
trexfeathers cde0432
Remove Get Started and Iris API from top level toctree.
trexfeathers dbd2cb4
Clearer wording about the purpose of the User Manual and User Guide.
trexfeathers 11d0763
Page summary improvements.
trexfeathers 77f93e6
Topic tag improvements.
trexfeathers 9f79cfe
Merge remote-tracking branch 'upstream/main' into diataxis
trexfeathers 19d9482
Fix admonition.
trexfeathers 691547f
Update lock files.
trexfeathers 5847d3f
More accurate caption for plot_atlantic_profiles.
trexfeathers c6b84eb
Merge remote-tracking branch 'upstream/main' into diataxis
trexfeathers 9454a76
Diataxis metadata for s3_io.rst.
trexfeathers 5ed97c8
Review actions.
trexfeathers 7b73156
Rename topic_statistics.
trexfeathers 5887430
Less aggressive phrasing about how to navigate.
trexfeathers 2897699
Update lock files.
trexfeathers 02fad05
Adapt to sphinx-needs v7.
trexfeathers e818714
What's New entry.
trexfeathers 9710ddb
Merge branch 'main' into diataxis
trexfeathers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| {# Render plain clickable text links for each tag #} | ||
| {% if tags %} | ||
| :strong:`Tags:` {{ " " }} {%- for t in tags -%} | ||
| {%- if t and t.startswith('topic_') -%} | ||
| :ref:`{{ t }} <{{ t }}>` | ||
| {%- else -%} | ||
| {{ t }} | ||
| {%- endif -%} | ||
| {%- if not loop.last %} | {% endif -%} | ||
| {%- endfor %} | ||
| {% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| # Copyright Iris contributors | ||
| # | ||
| # This file is part of Iris and is released under the BSD license. | ||
| # See LICENSE in the root of the repository for full licensing details. | ||
| # TODO: header | ||
| # TODO: docstrings/comments. How to document an extension/directive? | ||
| # TODO: linting | ||
|
|
||
| # TODO: include a validation routine, calling to sphinx-needs to confirm that | ||
| # all User Manual pages have the minimum metadata. | ||
| # - sphinx-need directive | ||
| # - :tags: including a topic_xxx tag | ||
| # - think sphinx-needs will already insist on a valid type? | ||
| # - think sphinx-needs will already insist on a title? | ||
| # - think sphinx-needs will already insist on a description? | ||
| # - as it stands this would exclude all section indexes, unless the section | ||
| # indexes get their own Diataxis tab. | ||
|
|
||
| from pathlib import Path | ||
| import enum | ||
| import re | ||
|
|
||
| from docutils import nodes # type: ignore[import-untyped] | ||
| from docutils.parsers.rst import Directive # type: ignore[import-untyped] | ||
| from docutils.statemachine import StringList # type: ignore[import-untyped] | ||
|
|
||
|
|
||
| class Diataxis(enum.StrEnum): | ||
| # TODO: should user manual section indexes also get their own Diataxis tab? | ||
| # This would allow topic-based filtering, and allow all pages to be found | ||
|
trexfeathers marked this conversation as resolved.
Outdated
|
||
| # through the same route. | ||
|
|
||
| ALL = "all" | ||
| TUTORIAL = "tutorial" | ||
| HOW_TO = "how-to" | ||
| REFERENCE = "reference" | ||
| EXPLANATION = "explanation" | ||
|
|
||
|
|
||
| DIATAXIS_CAPTIONS = { | ||
| Diataxis.TUTORIAL: "Guided lessons for understanding a topic. (Supports **study**, via **action**)", | ||
| Diataxis.HOW_TO: "Step by step instructions for achieving a specific goal. (Supports **work**, via **action**)", | ||
| Diataxis.EXPLANATION: "In-depth discussion for understanding concepts. (Supports **study**, via **theory**)", | ||
| Diataxis.REFERENCE: "Concise information to look up when needed. (Supports **work**, via **theory**)", | ||
| } | ||
|
|
||
|
|
||
| class DiataxisDirective(Directive): | ||
| has_content = True | ||
|
|
||
| @staticmethod | ||
| def _indent(text: str) -> str: | ||
| indented = [" " + line for line in text.splitlines()] | ||
| return "\n".join(indented) | ||
|
stephenworsley marked this conversation as resolved.
Outdated
|
||
|
|
||
| def _needtable(self, types: Diataxis, tags: str) -> str: | ||
| options = [ | ||
| ':columns: id as "Link";title;content as " "', | ||
| ":colwidths: 10;30;60", | ||
| ":style: table", | ||
| ":filter_warning: No pages for this filter.", | ||
| ] | ||
| # TODO: should the table somehow include what section the page belongs | ||
|
trexfeathers marked this conversation as resolved.
Outdated
|
||
| # to? This isn't standard sphinx-needs metadata so would need | ||
| # `needs_extra_options` in conf.py. | ||
| if types is not Diataxis.ALL: | ||
| options.append(f":types: {types}") | ||
| # TODO: is looking for `topic_all` brittle hard-coding? | ||
|
trexfeathers marked this conversation as resolved.
Outdated
|
||
| if tags != "topic_all": | ||
| options.append(f":tags: {tags}") | ||
| options_str = "\n".join(options) | ||
| needtable = "\n".join([ | ||
| ".. needtable::", | ||
| self._indent(options_str), | ||
| ]) | ||
| return needtable | ||
|
|
||
| def _tab_item(self, diataxis: Diataxis, tags: str) -> str: | ||
| needtable = self._needtable(types=diataxis, tags=tags) | ||
| tab_item_title = diataxis.capitalize() | ||
| # TODO: should there be a caption for ALL as well? Even if that's just | ||
| # for visual consistency. | ||
|
trexfeathers marked this conversation as resolved.
Outdated
|
||
| caption = DIATAXIS_CAPTIONS.get(diataxis, "") | ||
| if diataxis is not Diataxis.ALL: | ||
| tab_item_title += "s" | ||
| content = [ | ||
| f":sync: {diataxis}", | ||
| "", | ||
| caption, | ||
| "", | ||
| needtable, | ||
| ] | ||
| content_str = "\n".join(content) | ||
| tab_item = "\n".join([ | ||
| f".. tab-item:: {tab_item_title}", | ||
| self._indent(content_str), | ||
| ]) | ||
| return tab_item | ||
|
|
||
| def run(self): | ||
| rst_path = Path(self.state.document['source']) | ||
| # user_manual.index.rst | ||
| if not (rst_path.parent.name == "user_manual" and rst_path.name == "index.rst"): | ||
| message = "Expected directive to only be used in user_manual/index.rst" | ||
| error = self.state_machine.reporter.error( | ||
| message, line=self.lineno | ||
| ) | ||
| return [error] | ||
| label_pattern = re.compile(r"^\.\. _(topic_.+):$", re.MULTILINE) | ||
| topic_labels = label_pattern.findall(rst_path.read_text()) | ||
| badges = { | ||
| label: "bdg-ref-primary" if label == self.content[0] else "bdg-ref-primary-line" | ||
| for label in topic_labels | ||
| } | ||
| # Parse the badges as RST. | ||
| node = nodes.Element() | ||
| self.state.nested_parse( | ||
| StringList([f":{badge}:`{label}`" for label, badge in badges.items()]), | ||
| self.content_offset, | ||
| node | ||
| ) | ||
|
|
||
| tab_items = [ | ||
| self._tab_item(diataxis=diataxis, tags=self.content[0]) | ||
| for diataxis in Diataxis | ||
| ] | ||
| tab_items_str = "\n\n".join(tab_items) | ||
| tab_set = "\n".join([ | ||
| ".. tab-set::", | ||
| "", | ||
| self._indent(tab_items_str), | ||
| ]) | ||
| # Parse the tab set as RST. | ||
| self.state.nested_parse( | ||
| StringList(tab_set.splitlines()), | ||
| self.content_offset, | ||
| node | ||
| ) | ||
|
|
||
| return node.children | ||
|
|
||
|
|
||
| def setup(app): | ||
| app.add_directive("diataxis-page-list", DiataxisDirective) | ||
| return {"version": "0.1"} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| .. comment: | ||
| now that User Manual is the official top-level, and the User Guide is a | ||
| sub-section, the original labels have been relocated here. | ||
|
|
||
| .. _user_guide_index: | ||
| .. _user_guide_introduction: | ||
| .. _user_manual_index: | ||
|
|
||
| User Manual | ||
| =========== | ||
|
|
||
| Welcome to the Iris User Manual! | ||
|
stephenworsley marked this conversation as resolved.
|
||
|
|
||
| We encourage exploring our User Manual pages using the tabbed sections below, | ||
| which combine the `Diataxis`_ framework and topic-based filters to find content | ||
| best suited to your purpose today. Alternatively, you can use the sidebar to | ||
| navigate by section. | ||
|
|
||
| .. todo: | ||
| Should the sections also be offered as another Diataxis tab? This would allow | ||
| topic-based filtering, and allow all pages to be found through the same | ||
| route. | ||
|
trexfeathers marked this conversation as resolved.
Outdated
|
||
|
|
||
| .. comment: | ||
| The tree structure for user_manual is specified here. As mentioned in the | ||
| text, we prefer readers to use the tabbed sections below, so the toctree is | ||
| hidden - not rendered in the text, only in the sidebar. This toctree is | ||
| expected to be exclusively section_indexes/* pages; with those pages | ||
| providing the remaining sub-structure. | ||
|
|
||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
| :hidden: | ||
|
|
||
| section_indexes/userguide | ||
| section_indexes/dask_best_practices | ||
| section_indexes/mesh_support | ||
| section_indexes/metadata_arithmetic | ||
| section_indexes/community | ||
| section_indexes/general | ||
|
stephenworsley marked this conversation as resolved.
|
||
|
|
||
| .. _topic_all: | ||
|
|
||
| All | ||
| --- | ||
|
|
||
| .. diataxis-page-list:: topic_all | ||
|
|
||
| By Topic | ||
| -------- | ||
|
|
||
| .. _topic_data_model: | ||
|
|
||
| topic: ``data_model`` | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| Pages about the :class:`~iris.cube.Cube` class and its associated components | ||
| such as :class:`~iris.coords.Coord` and :class:`~iris.mesh.Mesh`. | ||
|
|
||
| .. diataxis-page-list:: topic_data_model | ||
|
|
||
| .. _topic_load_save: | ||
|
|
||
| topic: ``load_save`` | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| Pages about reading from files into the data model, and writing from the data | ||
| model to files. | ||
|
|
||
| .. diataxis-page-list:: topic_load_save | ||
|
|
||
| .. _topic_lazy_data: | ||
|
|
||
| topic: ``lazy_data`` | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| Pages about Iris' implementation of parallel and out-of-core data handling, via | ||
| Dask. See :term:`Lazy Data`. | ||
|
|
||
| .. diataxis-page-list:: topic_lazy_data | ||
|
|
||
| .. _Diataxis: https://diataxis.fr/ | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.