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

GitHub edit link is aggressively stripped #1788

Closed
KeithWoods opened this issue Oct 23, 2015 · 5 comments
Closed

GitHub edit link is aggressively stripped #1788

KeithWoods opened this issue Oct 23, 2015 · 5 comments
Labels
Bug A bug

Comments

@KeithWoods
Copy link

Hi

I'm trying to override the value of github_repo which is used to create the 'edit in git hub' link on the doco site. In my case this value isn't the default (which appears to be that of the RTD project name).

I've set html_context in my conf.py to override github_repo however I see in the build logs that RTD seems to extend this and blow away my changes:

# my config

html_context = {
    'github_repo': "esp.github.io",
}


... later in the same script ... 

###########################################################################
#          auto-created readthedocs.org specific configuration            #
###########################################################################


#
# The following code was added during an automated build on readthedocs.org
# It is auto created and injected for every build. The result is based on the
# conf.py.tmpl file found in the readthedocs.org codebase:
# https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl
#

... later in the same script ... 

#Add project information to the template context.
context = {
    'using_theme': using_rtd_theme,
    'html_theme': html_theme,
    'current_version': "latest",
    'MEDIA_URL': "https://media.readthedocs.org/",
    'PRODUCTION_DOMAIN': "readthedocs.org",
    'versions': [
    ("latest", "/en/latest/"),
    ],
    'downloads': [ 
    ("pdf", "//readthedocs.org/projects/esp/downloads/pdf/latest/"),
    ("htmlzip", "//readthedocs.org/projects/esp/downloads/htmlzip/latest/"),
    ("epub", "//readthedocs.org/projects/esp/downloads/epub/latest/"),
    ],
    'slug': 'esp',
    'name': u'Evented State Processor (ESP)',
    'rtd_language': u'en',
    'canonical_url': 'http://esp.readthedocs.org/en/latest/',
    'analytics_code': '',
    'single_version': False,
    'conf_py_path': '/./',
    'api_host': 'https://readthedocs.org/',
    'github_user': 'esp',
    'github_repo': 'esp',
    'github_version': 'master',
    'display_github': True,
    'bitbucket_user': 'None',
    'bitbucket_repo': 'None',
    'bitbucket_version': 'master',
    'display_bitbucket': False,
    'READTHEDOCS': True,
    'using_theme': (html_theme == "default"),
    'new_theme': (html_theme == "sphinx_rtd_theme"),
    'source_suffix': SUFFIX,
    'user_analytics_code': '',
    'global_analytics_code': 'UA-17997319-1',

    'commit': '98303330',

}
if 'html_context' in globals():
    html_context.update(context)
else:
    html_context = context

I need to override this value as I'm using RTD to host a single doco site for 2 projects (1,2).
I need github_repo to be esp.github.io so it correctly points to the doco src.

I think the fix to in rtfd's conf.py may be something like this (assuming it's safe to replace html_context):

if 'html_context' in globals():
    context.update(html_context)

html_context = context

Possibly related to #743

Appreciate any help or suggestions on how to fix the link this

Keith

@KeithWoods KeithWoods changed the title Can't override values in html_context Can't github link / Can't override values in html_context Oct 24, 2015
@KeithWoods KeithWoods changed the title Can't github link / Can't override values in html_context Can't: change github link / override values in html_context Oct 24, 2015
@agjohnson
Copy link
Contributor

The github repo that we link to is the github repo that is set up with the project. I'm curious why this needs to be changed. If your source repo isn't correct, can't you change it on the project?

@agjohnson agjohnson added the Support Support question label Oct 30, 2015
@KeithWoods
Copy link
Author

Hi Again, sorry for the very late reply.

The github repo that we link to is the github repo that is set up with the project. I'm curious why this needs to be changed. If your source repo isn't correct, can't you change it on the project?

I don't know if this is working for me. Both the repository url and project homepage (under the RTFD admin) is set to my documentation repository on github, I'd expect the link to point to that. However when I created the RTFD project I used a different name, simple 'esp'.

The reason my RTFD project name is different for my repository is because my RTFD site is really for my organisation https://github.com/esp, not that organisations sub repositories. In my case all the sub repos are just implementations of a similar pattern that can be discussed in one documentation site.

It appears that that the 'edit in git hub' link is actually inferred from the RTFD project name, not admin settings that point to the doco source repo.

I hope this makes sense :)

@agjohnson
Copy link
Contributor

It seems what might be happening here is that the .github.io is being removed from you repository name? The github URL is generated using your repo path, which looks correct. Seems this is a bug rather than a project misconfiguration.

@agjohnson agjohnson added Bug A bug and removed Support Support question labels Feb 27, 2016
@agjohnson agjohnson changed the title Can't: change github link / override values in html_context GitHub edit link is aggressively stripped Feb 27, 2016
@KeithWoods
Copy link
Author

Thanks for coming back. Not sure what I'll do on my end for now but at least the issues is capture for now.

@stsewd
Copy link
Member

stsewd commented Jan 10, 2018

I was able to reproduce this, the issue is on the regex that checks the repo url, the .github part is the problem, while a patch is provided you can use this url form https://github.com/{user}/{user}.github.io.git. Note the final .git.

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

No branches or pull requests

3 participants