sphinx-book-theme icon indicating copy to clipboard operation
sphinx-book-theme copied to clipboard

Wrong path for use_edit_page_button

Open tkaraouzene opened this issue 4 years ago • 3 comments

Describe the problem

Hi everyone and first of all thanks for this wonderful sphinx theme 👏

The behavior of the "use_edit_page_button" is not working as expected. Since my repository is hosted by my company in a dedicated GitHub Enterprise, the base URL is not https://github.com/ but https://github.my-compagny.com/

bellow are my html_theme_option:

html_theme_options = {
    "repository_url": "path/to/my/repo",
    "use_repository_button": True,
    "use_issues_button": True,
    "use_edit_page_button": True,
}

Both use_repository_button and use_issues_button works perfectly well. However the edit button point to the standard https://github.com/ (and so return a 404 error).

Steps to reproduce

As said above the issue occurs because my repository is hosted on a GitHub Enterprise. So I cannot provide you a step to reproduce the issue.

However I think that using the repository_url as base for the use_edit_page_button should fix the issue.

The version of Python you're using

python version: 3.8.8

Your operating system

Windows 10

Versions of your packages

sphinx-book-theme==0.1.6

tkaraouzene avatar Oct 22 '21 07:10 tkaraouzene

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Oct 22 '21 07:10 welcome[bot]

Can we introduce a configuration option 'git_base_url' or similar to define the base URL?

The edit button's URL is currently generated from the method get_edit_url

https://github.com/executablebooks/sphinx-book-theme/blob/526956165f3fda3e5faaf53ffc39081715702f6d/src/sphinx_book_theme/header_buttons/init.py#L107

derieved from a context that is initialised in another place:

https://github.com/executablebooks/sphinx-book-theme/blob/5721a63c5507c185fdf0cb51e008a70e21fe3874/src/sphinx_book_theme/header_buttons/launch.py#L18

Yet we don't find other occurencies of get_edit_url within the repository here.

  • https://github.com/executablebooks/sphinx-book-theme/search?q=get_edit_url

But we can find another issue (here!) that discusses this already:

  • https://github.com/executablebooks/sphinx-book-theme/search?q=get_edit_url&type=issues

So we may as well close here in favour of the much older and more detailed-out

  • #114

Downstream this is known as:

  • https://github.com/executablebooks/jupyter-book/issues/925
  • https://github.com/executablebooks/jupyter-book/issues/1310
  • https://github.com/executablebooks/jupyter-book/issues/1333

There are workarounds documented in

  • https://github.com/executablebooks/sphinx-book-theme/issues/114#issuecomment-927298905

and in

  • https://github.com/executablebooks/jupyter-book/issues/925#issuecomment-790946913

almereyda avatar Sep 30 '22 10:09 almereyda

FWIW, a more generic solution is implemented in Furo now, via sphinx-basic-ng's edit-this-page: https://sphinx-basic-ng.readthedocs.io/en/latest/usage/components/edit-this-page/

The user-facing documentation of the functionality in Furo is at https://pradyunsg.me/furo/customisation/edit-button/.

It might make sense to migrate to that style here as well?

pradyunsg avatar Sep 30 '22 10:09 pradyunsg

Did just bump into this problem as well, using this theme and wanted to point to an internally hosted Gitlab instance.

As far as I am able to tell, we are based on the pydata-sphinx-theme. When I studied their documentation, I found this section: https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/source-buttons.html

The theme supports Gitlab, Github and Bitbucket, plus it does also allow to set a custom template for the edit URL.

Looking into the code, I believe the pydata theme has the implementation around this function here: https://github.com/pydata/pydata-sphinx-theme/blob/main/src/pydata_sphinx_theme/init.py#L782

What seems to cause the trouble is the implementation which this theme has, it seems to always configure github related values, so that the original functionality cannot be used anymore: https://github.com/executablebooks/sphinx-book-theme/blob/master/src/sphinx_book_theme/header_buttons/init.py#L95

I've not yet had the time to look deeper into this, so please take my pointers above with a grain of salt. My impression may be wrong.

Workaround

What I've found as a workaround for my case is to use edit_page_url_template, since the code from the pydata theme is giving priority to this setting.

johbo avatar Feb 13 '23 14:02 johbo