-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat!: retrieve all markdown pages #266
Conversation
@@ -0,0 +1,52 @@ | |||
# Modules for Python Storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is generated as part of the library's structure for handwritten
library. We shouldn't use this in production, but WAI with the way that the directory is set up. In practice, this will need to be removed in the actual library and have the Sphinx config re-structured.
docfx_yaml/extension.py
Outdated
pkg_toc_queue = [package for package in pkg_toc_yaml] | ||
for entry in pkg_toc_queue: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use list(pkg_toc_yaml)
to create a copy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
docfx_yaml/extension.py
Outdated
pkg_toc_queue = [package for package in pkg_toc_yaml] | ||
for entry in pkg_toc_queue: | ||
if (children := entry.get('items')): | ||
pkg_toc_queue.extend(children) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This modifies the list being iterated over, which is generally bad. Consider something like flatten_items
which can be recursive and flattens the list of items
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Added _flatten_tocs
entry to address this.
docfx_yaml/markdown_utils.py
Outdated
base_markdown_dir = Path(app.builder.outdir).parent / "markdown" | ||
|
||
markdown_dir = ( | ||
base_markdown_dir / '/'.join(cwd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base_markdown_dir / '/'.join(cwd) | |
base_markdown_dir.joinpath(*cwd) |
(Using '/'
and pathlib
at the same time is a red flag.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thank you for this!
@@ -4,6 +4,16 @@ | |||
- href: changelog.md | |||
name: Changelog | |||
- items: | |||
- href: blobs.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these test files need to be as long as they are?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The content should be separated, but works as intended - blobs
and buckets
should be filtered but there is no class entry with the exact name, but blob
and bucket
exists. This is the case for ACL
and other libraries: there is a markdown file generated but not moved over as we see that there is an entry for which it exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Please take a look again.
docfx_yaml/extension.py
Outdated
pkg_toc_queue = [package for package in pkg_toc_yaml] | ||
for entry in pkg_toc_queue: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
docfx_yaml/markdown_utils.py
Outdated
base_markdown_dir = Path(app.builder.outdir).parent / "markdown" | ||
|
||
markdown_dir = ( | ||
base_markdown_dir / '/'.join(cwd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thank you for this!
@@ -4,6 +4,16 @@ | |||
- href: changelog.md | |||
name: Changelog | |||
- items: | |||
- href: blobs.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The content should be separated, but works as intended - blobs
and buckets
should be filtered but there is no class entry with the exact name, but blob
and bucket
exists. This is the case for ACL
and other libraries: there is a markdown file generated but not moved over as we see that there is an entry for which it exists.
@@ -4,6 +4,16 @@ | |||
- href: changelog.md | |||
name: Changelog | |||
- items: | |||
- href: blobs.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docfx_yaml/extension.py
Outdated
pkg_toc_queue = [package for package in pkg_toc_yaml] | ||
for entry in pkg_toc_queue: | ||
if (children := entry.get('items')): | ||
pkg_toc_queue.extend(children) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Added _flatten_tocs
entry to address this.
docfx_yaml/extension.py
Outdated
toc_queue.extend(_flatten_toc(children)) | ||
toc_queue.extend(children) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still modifying toc_queue
while looping over it. Can you iterate over toc_yaml_entry
instead?
If I'm understanding correctly, we don't need a queue at all. Just need to iterate over the "graph" and put it all into a single list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops 🤦 Made updates.
Please take a look again! |
docfx_yaml/extension.py
Outdated
for entry in toc_yaml_entry: | ||
if (children := entry.get('items')): | ||
entries.extend(_flatten_toc(children)) | ||
entries.extend(children) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this line end up double-adding? _flatten_toc
is called with children
, which will then return children
(and more), then we add children
again right here.
Seems like this needs a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦🤦 Yes you're right. Removed the redundant line, added unit test coverage as well. I didn't add it before because it required sphinx.app
... before, but not anymore so fine to add now.
Please take a look again! |
Recovered all markdown pages in nested directory structures. This was not correctly retrieved as I was only looking in the top directory.
Few things that's happening (happy to break down, but was hard to do so to have all the moving parts in one picture):
Only the
handwritten
TOC is updated and works as expected,gapic-combo
andgapic-auto
doesn't contain any markdown pages in nested directories.Some markdown pages might come with a mix of handwritten guides and autogenerated API content. I plan on working with the library maintainers to have this updated throughout (<10) for the purpose of this plugin that separates Sphinx HTML and DocFX YAML content.
Breaking Change: Upgrading to using 3.9. All Python client libraries are able to use 3.9, so this is not a problem, but will be a backwards incompatible change.
Fixes #217.