Skip to content

Fix broken links #2170

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

Merged
merged 1 commit into from
Jan 2, 2017
Merged

Fix broken links #2170

merged 1 commit into from
Jan 2, 2017

Conversation

pfheatwole
Copy link
Contributor

Fixes three broken links in the docs (one is just a broken anchor on Wikipedia, but still)

Cheers, and thanks for the tool!

@nicoddemus
Copy link
Member

Many thanks!

@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.816% when pulling ef90346 on gogoengie:broken-links into 78f0388 on pytest-dev:master.

@nicoddemus nicoddemus merged commit b769e41 into pytest-dev:master Jan 2, 2017
@pfheatwole pfheatwole deleted the broken-links branch January 3, 2017 00:31
@The-Compiler
Copy link
Member

How did you find out about those? Is this something we could integrate in our CI?

@pfheatwole
Copy link
Contributor Author

I encountered thetox broken link while reading "good practices". Once I'd opened the branch I figured I'd look around for other (subjectively) important links. I'm short on time, so I triaged with this:

$ cd pytest/doc/en
$ make linkcheck
$ grep broken _build/linkcheck/output.txt | cut -d: -f1 | uniq

In #1722 you discussed this method, but decided you'd like to avoid all those requests for every commit. (Reasonable, but I wasn't worried for my one-off run.) If you're looking for a compromise, you could check only those files affected by the commit set. For example, suppose something like:

$ cd pytest/doc/en
$ git diff --name-only HEAD~   # Suppose I deliberately broke links in these files
doc/en/goodpractices.rst
doc/en/assert.rst
doc/en/links.inc
$ git diff --name-only HEAD~ | cut -d/ -f3   # Use these as input to sphinx-build
goodpractices.rst
assert.rst
links.inc
$ sphinx-build -b linkcheck -d _build/doctrees -D latex_paper_size=letter . _build/linkcheck $(git diff --name-only HEAD~ | cut -d/ -f3)
Running Sphinx v1.5
loading pickled environment... done
building [mo]: targets for 0 po files that are specified
building [linkcheck]: 3 source files given on command line
updating environment: 0 added, 7 changed, 0 removed
reading sources... [100%] usage                                                 
links.inc:17: WARNING: Duplicate explicit target name: "virtualenv".
/home/peter/scratch/pytest/doc/en/goodpractices.rst:142: ERROR: Duplicate target name, cannot be used as a unique reference: "virtualenv".
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [ 33%] assert                                                 
(line  310) broken    http://example.com/blargh - 404 Client Error: Not Found for url: http://example.com/blargh
writing output... [ 66%] contents                                               
(line    6) ok        https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf
writing output... [100%] goodpractices                                          
(line  157) ok        https://wiki.jenkins-ci.org/display/JENKINS/xUnit+Plugin
(line  147) broken    https://example.com/blargh - 404 Client Error: Not Found for url: https://example.com/blargh
(line  157) redirect  http://jenkins-ci.org/ - permanently to https://jenkins.io/index.html
(line  166) ok        https://pypi.python.org/pypi/pytest-runner
(line  147) redirect  http://testrun.org/tox - with Found to https://tox.readthedocs.io/en/latest/
(line  142) redirect  http://pypi.python.org/pypi/pip - permanently to https://pypi.python.org/pypi/pip

build finished with problems, 2 warnings.

$ grep broken _build/linkcheck/output.txt | cut -d: -f1 | uniq
assert.rst
goodpractices.rst
$  # Notice, it missed breakage in `links.inc`

Note, this example is intentionally incomplete: the last commit changed doc/en/links.inc, but sphinx-build seems to ignore non-output-targets in the list of filenames. Still, it's an idea. :-)

Hope that helps!

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.

4 participants