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

Sphinx: Link each entity to its source code on github #262

Merged
merged 1 commit into from
Jun 7, 2015

Conversation

f0k
Copy link
Member

@f0k f0k commented May 21, 2015

This links each entity to its source file on github. This should make it a lot easier for people to suggest edits to docstrings.
Numpy tweaked this further (https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L286), in two respects:

  • They link to the correct line in the file, while this PR just links to the file per se.
  • They link to the correct version of the source code, while this PR just links to the latest master.

It should be possible to copy and adapt their code, but I don't have the time now -- I'd welcome any PRs to my PR!

@benanne
Copy link
Member

benanne commented May 21, 2015

Looks good! It would be good to make it differentiate between master and release already, I have a feeling we'll forget about it if we wait until the release.

@f0k
Copy link
Member Author

f0k commented May 22, 2015

It would be good to make it differentiate between master and release already

Please have a look at the numpy code: They solve this via numpy.__version__. Maybe there's a different way when compiling online at readthedocs, but to produce the correct links locally, that's the way to go. I've added this to our release todo list: #74 (comment)

I have a feeling we'll forget about it if we wait until the release.

Yes, in any case I wouldn't merge this without copying in the code I linked to. Without links to the correct line number it would be a step back from what we have.

@f0k f0k mentioned this pull request May 23, 2015
@f0k f0k force-pushed the doc-link-to-github branch 2 times, most recently from e6498fc to faf5e2f Compare June 5, 2015 16:40
@f0k f0k changed the title [WIP] Sphinx: Link each entity to its source code on github Sphinx: Link each entity to its source code on github Jun 5, 2015
@f0k
Copy link
Member Author

f0k commented Jun 5, 2015

Rebased and amended. It now links to the correct line number in the correct file in the correct branch/tag. Ready for reviewing and merging.

# The full version, including alpha/beta/rc tags.
release = '0.1'
release = lasagne.__version__
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 saves another version string update that could easily be missed; numpy does it the same way. Let's see how readthedocs thinks about that. I've read that you may need to configure readthedocs to use virtualenv.

Copy link
Member

Choose a reason for hiding this comment

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

Why would it work with virtualenv but not otherwise? I'm not sure how it's currently set up - there seem to be multiple virtualenv-related settings, some of them are enabled and some aren't. It's a bit unclear what they all do. I remember having to tinker with them for a while before everything would work, though.

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 line requires "import lasagne" beforehand, maybe this is not universally fine. I also don't know exactly how Sphinx works. We can just merge and see what happens.

Copy link
Member

Choose a reason for hiding this comment

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

Fine by me :)

@benanne
Copy link
Member

benanne commented Jun 5, 2015

Not much to say about this as I'm not very familiar with how Sphinx works. Everything looks fine to me.

f0k added a commit that referenced this pull request Jun 7, 2015
Sphinx: Link each entity to its source code on github
@f0k f0k merged commit e3a07e5 into Lasagne:master Jun 7, 2015
@f0k f0k deleted the doc-link-to-github branch June 7, 2015 14:40
@f0k
Copy link
Member Author

f0k commented Jun 7, 2015

Okay, merged and crossing fingers.

/edit: It works!

@f0k
Copy link
Member Author

f0k commented Jun 7, 2015

Wait, it doesn't work for lasagne.layers, it thinks the definitions reside in lasagne/layers.py although they are defined in submodules imported in lasagne/layers/__init__.py. Sorry for not checking all the pages beforehand.

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

Successfully merging this pull request may close these issues.

None yet

2 participants