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

Add "Edit on GitHub" links #3398

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ def _load_theme(
# a list of builtin themes.
html_theme = HTML_THEME

print("Using theme: " + HTML_THEME)

# ## Edit on GitHub feature, inherited by renku theme from rtd theme
html_context = {
'display_github': True,
'github_user': 'teemtee',
'github_repo': 'tmt',
'github_version': 'main/docs/'
}

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
Expand Down
6 changes: 6 additions & 0 deletions docs/scripts/generate-stories.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def main() -> None:
logger.info(f'Generating rst files from {area}')

with open(f"{area.lstrip('/')}.rst", 'w') as doc:
# Metadata -
# https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html
doc.write(
f':github_url: https://github.com/teemtee/tmt/blob/main{area}'
Copy link
Collaborator

@happz happz Dec 10, 2024

Choose a reason for hiding this comment

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

  1. The URL is invalid for forks and every branch beyond main
  2. Some areas are directories, some are fmf files. It's not important to fmf, which can handle both correctly, but here we would need to make a distinction. https://github.com/teemtee/tmt/blob/main/stories/install does not exist, https://github.com/teemtee/tmt/blob/main/stories/install.fmf does.

Every story object should have web_link() method, which returns a link to the corresponding fmf file, that would be perfect, but that's for "edit on github" per section rather than per page. My initial idea would be to collect all web links for the area stories, and find their common, shared prefix and use that one. I don't like it, but right now I don't have a better one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The URL points to main, but it should be valid as long as file path in repo doesn't change. Does it makes sense to propose edits to branches?

For .fmf vs directory, the generate script knows which template to invoke, and it can set the URL correctly. What is needed, is the list of this generated entries to check, and generators that produce them. To make sure nothing falls apart.

)
doc.write('\n\n')
# Anchor and title
doc.write(f'.. _{area}:\n\n')
doc.write(f"{title}\n{'=' * len(title)}\n")
Expand Down
Loading