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

Components Rendering: Support nested readmes #609

Merged
merged 4 commits into from
May 2, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions scripts/docs-collator/ComponentRenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ def render(self, component):
module_download_dir = os.path.join(self.download_dir, 'modules', component)

files = io.get_filenames_in_dir(module_download_dir, README_MD, True)
files += io.get_filenames_in_dir(module_download_dir, '*.md', True)

images = io.get_filenames_in_dir(module_download_dir, '*.png', True)

for file in files:
if file.endswith(CHANGELOG_MD):
continue
self.__render_doc(component, file)

for image in images:
io.copy_file(image, os.path.join(self.docs_dir, component, os.path.relpath(image, module_download_dir)))

def __render_doc(self, component, file):
module_download_dir = os.path.join(self.download_dir, 'modules')

Expand All @@ -43,11 +51,12 @@ def __render_doc(self, component, file):
relative_path = os.path.relpath(file, module_download_dir)
result_file = os.path.join(self.docs_dir, os.path.relpath(file, module_download_dir)) # <module-name>/README.md

label = component
title = component
name = component if os.path.basename(file) == "README.md" else os.path.basename(file).replace(".md", "")
label = name
title = name
github_edit_url = f"https://github.com/{GITHUB_REPO}/blob/master/modules/{relative_path}"

if len(relative_path.split('/')) > 2: # this is submodule
if len(relative_path.split('/')) > 2 and relative_path.split('/')[1] != 'docs' : # this is submodule
Copy link
Member Author

Choose a reason for hiding this comment

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

This smells. Though I'm not sure how we want to handle this, we need to enforce either docs/ or modules but think of tgw which uses tgw/hub as a component, it is nested, therefore I stuck with docs as an exception to the rule (where it's not a directory of TF)

submodule_name = os.path.basename(os.path.dirname(result_file))

label = submodule_name
Expand Down
Loading