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

"Edit on Gitlab" not showing #10057

Closed
Hyrla opened this issue Feb 22, 2023 · 7 comments
Closed

"Edit on Gitlab" not showing #10057

Hyrla opened this issue Feb 22, 2023 · 7 comments
Labels
Support Support question

Comments

@Hyrla
Copy link

Hyrla commented Feb 22, 2023

Details

Expected Result

I'm trying to replace the default link "View page source" by "Edit on Gitlab". I have added this html context to my conf.py and recompiled.

html_context = {
    "display_gitlab": True, # Integrate Gitlab
    "gitlab_host": "gitlab.esiea.fr", # Gitlab URL
    "gitlab_user": "esieabot", # Username
    "gitlab_repo": "esieabot-docs/rtd-francais", # Repo name
    "gitlab_version": "main", # Version
    "conf_py_path": "/source/", # Path in the checkout to the docs root
}

Actual Result

The link remains "View page source" and not "Edit on Gitlab". Am I doing something wrong ?

@humitos humitos added the Support Support question label Feb 22, 2023
@Hyrla
Copy link
Author

Hyrla commented Feb 22, 2023

Problem found. Readthedocs is overwriting html_context (why??). Here is the conf.py as generated by Read the Docs:

[...]

# My context as defined in my conf.py
html_context = {
    "display_gitlab": True, # Integrate Gitlab
    "gitlab_host": "gitlab.esiea.fr", # Gitlab URL
    "gitlab_user": "esieabot", # Username
    "gitlab_repo": "esieabot-docs/rtd", # Repo name
    "gitlab_version": "main", # Version
    "conf_py_path": "/docs/source/", # Path in the checkout to the docs root
}

[...]

# Autogenerated content by Read the Docs
if 'html_context' in globals():
    
    html_context.update(context) # It erased everything set by user because update() is used the wrong way!
    
else:
    html_context = context

I looked at how the file is generated and here is what I found: https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl

if 'html_context' in globals():
    {% if dont_overwrite_sphinx_context %}
    for key in context:
        if key not in html_context:
            html_context[key] = context[key]
    {% else %}
    html_context.update(context)
    {% endif %}
else:
    html_context = context

So there is a flag called dont_overwrite_sphinx_context to don't overwrite the user context (??) and to enable it you have to contact the support (??) https://docs.readthedocs.io/en/stable/feature-flags.html

Do you have to pay to set your own edit button correctly?

@Hyrla
Copy link
Author

Hyrla commented Feb 22, 2023

There was a PR 5 years ago that added this feature flag: #4349

As far as I understand it, the idea is to use the settings set by the user on the dashboard and not the ones set in conf.py (which is strange but why not, I'm not an expert in Read the Docs).

So I think the true issue is there is no GUI to let the user sets the gitlab settings when the repository is not on gitlab.com but on a self hosted instance.

@sravel
Copy link

sravel commented Feb 24, 2023

Hello, I also want to add link to gitlab and I try to used Flag
https://docs.readthedocs.io/en/stable/feature-flags.html#available-flags
I append on conf.py like

# add flag for readthedocs https://docs.readthedocs.io/en/stable/feature-flags.html#available-flags
DONT_OVERWRITE_SPHINX_CONTEXT = 'dont_overwrite_sphinx_context'

and also try global variables for readthedocs
image
but fail to add link

@Hyrla
Copy link
Author

Hyrla commented Feb 26, 2023

@sravel hi, the feature flag can’t be enabled with an environment variable. It can only be done by the readthedocs’ admins. I contacted them with the support page, they enabled the flag and now it’s working.

The true issue is there is no way to configure it properly without this flag.

@stsewd
Copy link
Member

stsewd commented Feb 27, 2023

Problem found. Readthedocs is overwriting html_context (why??).

This was done to keep backwards compatibility, but I think we should just enable it for all projects, maybe a small set of projects will break, but the solution should be easy.

@sravel please contact support via https://readthedocs.org/support/.

@humitos
Copy link
Member

humitos commented Feb 27, 2023

This was done to keep backwards compatibility, but I think we should just enable it for all projects, maybe a small set of projects will break, but the solution should be easy.

I'm 👍🏼 on enabling this broadly and start thinking about removing this feature flag completely. We can start by enabling it by default to all new projects if we are not already.

@stsewd
Copy link
Member

stsewd commented May 4, 2023

Closing this in favor of #10293.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support Support question
Projects
None yet
Development

No branches or pull requests

4 participants