new: Add generated documentation website#639
Open
lgarber-akamai wants to merge 41 commits intolinode:devfrom
Open
new: Add generated documentation website#639lgarber-akamai wants to merge 41 commits intolinode:devfrom
lgarber-akamai wants to merge 41 commits intolinode:devfrom
Conversation
a28e46a to
9bb4769
Compare
45fb447 to
c4da9d4
Compare
baf5659 to
8f1cd4f
Compare
lgarber-akamai
commented
Sep 6, 2024
|
|
||
| return self._handle_list_items(list_items, parsed) | ||
|
|
||
| def build_parser( |
Contributor
Author
There was a problem hiding this comment.
I split this into multiple functions so we can extract the generated usage text for use in the docs
lgarber-akamai
commented
Sep 6, 2024
linodecli/baked/parsing.py
Outdated
Comment on lines
-125
to
+147
| relevant_lines = None | ||
|
|
||
| for i, line in enumerate(target_lines): | ||
| def __simplify(sentence: str) -> Optional[str]: | ||
| # Edge case for descriptions starting with a note | ||
| if line.lower().startswith("__note__"): | ||
| continue | ||
| if sentence.lower().startswith("__note__"): | ||
| return None | ||
|
|
||
| sentence = strip_techdocs_prefixes(sentence) | ||
|
|
||
| relevant_lines = target_lines[i:] | ||
| break | ||
| # Check that the sentence still has content after stripping prefixes | ||
| if len(sentence) < 2: | ||
| return None | ||
|
|
||
| if relevant_lines is None: | ||
| return sentence + "." | ||
|
|
||
| # Find the first relevant sentence | ||
| result = next( | ||
| simplified | ||
| for simplified in iter( | ||
| __simplify(sentence) | ||
| for sentence in REGEX_SENTENCE_DELIMITER.split(description) | ||
| ) | ||
| if simplified is not None | ||
| ) | ||
|
|
||
| if result is None: |
Contributor
Author
There was a problem hiding this comment.
I overhauled the logic in this function to account for some new cases I ran into
lgarber-akamai
commented
Sep 6, 2024
Comment on lines
+187
to
+192
| result_no_links, links = extract_markdown_links(result) | ||
|
|
||
| if len(links) > 0: | ||
| description += f" See: {'; '.join(links)}" | ||
| result_no_links += f" See: {'; '.join(links)}" | ||
|
|
||
| return unescape(markdown_to_rich_markup(description)), unescape(description) | ||
| return unescape(markdown_to_rich_markup(result_no_links)), unescape(result) |
Contributor
Author
There was a problem hiding this comment.
This was updated to store one mostly unchanged version and one fully formatted version of the description, giving us more flexibility in the docs
lgarber-akamai
commented
Sep 6, 2024
| self.load_baked() | ||
|
|
||
| def bake(self, spec): | ||
| def bake(self, spec: Dict[str, Any], file: Optional[IO[bytes]] = None): |
Contributor
Author
There was a problem hiding this comment.
These changes allow us to construct a mock CLI from a custom spec in unit tests
lgarber-akamai
commented
Sep 6, 2024
| T = TypeVar("T") | ||
|
|
||
|
|
||
| def sorted_actions_smart( |
Contributor
Author
There was a problem hiding this comment.
This doesn't live with the rest of the util functions because it can also be used in the command --help pages
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📝 Description
This pull request implements a new generated documentation site that is automatically pushed to GitHub Pages.
The below preview URLs can be preview the documentation site in your browser:
Rendering
This PR uses Sphinx with the Read the Docs theme to render documentation. The Sphinx configuration and all relevant static files are stored under the
docsdirectory.Command Documentation Generation
Due to the complexity and abundance of CLI commands, the logic to generate documentation pages for CLI commands is located in the
linodecli/documentationdirectory.The
linodecli/documentation/templatesdirectory contains various Jinja2 templates which are dynamically rendered using the structures defined inlinodecli/documentation/template_data.py.CLI documentation pages are rendered to a user-defined directory when
linode-cli generate-docsis called. This is an indirect dependency of themake generate-docstarget, which will automatically render the command documentation into thedocs/_generateddirectory before executing any Sphinx commands.Publishing
To automatically publish the documentation to a publicly available URL, this PR adds a new documentation.yml GitHub Actions workflow file.
This workflow has three jobs:
Build the documentation and upload it as an artifact
Pull down the built docs from the first step and commit them to the
_documentationbranchmain,dev)_documentationbranch automatically be created if it does not already exist.Pull down the built docs from the first step and upload them as a release asset.
The Documentation Branch
This PR uses a dedicated documentation branch because it allows us to make multiple versions of the documentation available at at time. Additionally, this allows us to manually rebase any sensitive/unwanted documentation details.
This branch stores all relevant versions as subdirectories, with the
latestdirectory andindex.htmlfiles being updated on-demand by job #2 (mentioned above).✔️ Testing
The following test steps assume you have pulled down this PR locally and run
make install.Unit Testing
Documentation Rendering
generate-docstarget:Ensure the documentation generates successfully.
Open the documentation index in your browser:
Publishing
new/doc-generationbranch on your fork containing the changes from this PR:BuildandCommit to Pages Branchjobs under theBuild Documentationworkflow run successfully under your fork.Deploy from a branch, the target branch to the_documentationbranch, and the path to/ (root).MYGHUSERNAME.github.io/linode-cli/new/doc-generation.new/doc-generationbranch.new/doc-generationbranch with the formatvX.X.X.MYGHUSERNAME.github.io/linode-cli/latest.📷 Preview
Configuration Page