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

Fix [src] hyperlinks in rustdoc #23213

Merged
merged 1 commit into from
Mar 19, 2015
Merged

Fix [src] hyperlinks in rustdoc #23213

merged 1 commit into from
Mar 19, 2015

Conversation

ipetkov
Copy link
Contributor

@ipetkov ipetkov commented Mar 9, 2015

  • rustdoc was doubly appending the file name to the path of where to
    generate the source files, meanwhile, the [src] hyperlinks were not
  • Added a flag to rustdoc::html::render::clean_srcpath to ignore the
    last path component, i.e. the file name itself to prevent the issue
  • This also avoids creating directories with the same name as source
    files, and it makes sure the link to main.css is correct as well.

Fixes #23192

@rust-highfive
Copy link
Contributor

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -1,4 +1,4 @@
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT
Copy link
Contributor

Choose a reason for hiding this comment

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

We've basically agreed to stop touching these. They're legal cargo-culting.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough.

@Gankra
Copy link
Contributor

Gankra commented Mar 9, 2015

Would it be possible to write a regression test for this?

@steveklabnik
Copy link
Member

🎊

@tomjakubowski
Copy link
Contributor

@ipetkov if you're not familiar with rustdoc integration/regression testing, look in the src/test/run-make/rustdoc-* directories. They are run with a Python script located at etc/htmldocck.py. In brief, the script parses directives from comments and tries to match text/patterns at a given XPath in an HTML document given by a file path.

You might want to check that a [src] link with some URL exists in an item's document, and then another one that checks that an HTML file exists at the relative path given by that URL.

@Gankra
Copy link
Contributor

Gankra commented Mar 9, 2015

@tomjakubowski Are you interested in being the unofficial-official reviewer for this? You're the most active in this codebase recently.

@ipetkov
Copy link
Contributor Author

ipetkov commented Mar 10, 2015

@tomjakubowski I wasn't until today, but it seemed pretty straight forward :)

Also the PR has been updated to include a regression test

@tomjakubowski
Copy link
Contributor

@ipetkov looks good to me, but I'd prefer if this regression had its own test. rustdoc-smoke is already vague enough and I'd rather it not get cluttered over time.

I'm also a little bit curious why this bug only cropped up recently. Generating [src] links worked fine (minus some special cases like the alloc crate bug) until a week or so ago and then it broke completely seemingly out of nowhere.

@ipetkov
Copy link
Contributor Author

ipetkov commented Mar 15, 2015

@tomjakubowski I'm really not sure what caused the breakage, though I have a feeling it might be related with reforming PathBuf because in the past it might not have included the file name when it was converted into an iterator (though I have not looked into it and I could be wrong).

@gankro @tomjakubowski I've updated the PR so that the regression tests are in their own test rather than in rustdoc-smoke and rebased against the updated master.

Sorry for the delay at updating this, my machine suffered from a hardware failure a few nights ago and I haven't had access to my files. I haven't tested (or built) these new updates, though I tried to double check the test cases, and hopefully the build will pass.

@@ -695,13 +695,18 @@ fn shortty(item: &clean::Item) -> ItemType {
/// static HTML tree.
// FIXME (#9639): The closure should deal with &[u8] instead of &str
// FIXME (#9639): This is too conservative, rejecting non-UTF-8 paths
fn clean_srcpath<F>(src_root: &Path, p: &Path, mut f: F) where
fn clean_srcpath<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F) where
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a brief mention of what keep_filename does to the docs?

@ipetkov
Copy link
Contributor Author

ipetkov commented Mar 17, 2015

@huonw Updated with docs!

@huonw
Copy link
Member

huonw commented Mar 18, 2015

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 18, 2015

📌 Commit cc27f29 has been approved by huonw

@bors
Copy link
Collaborator

bors commented Mar 18, 2015

⌛ Testing commit cc27f29 with merge 8165036...

@Manishearth
Copy link
Member

Test breaks on a mac?

http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4122/steps/test/logs/stdio

----- /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/src/test/run-make/rustdoc-src-links/ --------------------
------ stdout ---------------------------------------------
DYLD_LIBRARY_PATH="/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/obj/x86_64-apple-darwin/test/run-make/rustdoc-src-links:/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/obj/x86_64-apple-darwin/stage2/lib:" /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/obj/x86_64-apple-darwin/stage2/bin/rustdoc -w html -o /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/obj/x86_64-apple-darwin/test/run-make/rustdoc-src-links/doc foo.rs
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/src/etc/htmldocck.py /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/obj/x86_64-apple-darwin/test/run-make/rustdoc-src-links/doc foo.rs

------ stderr ---------------------------------------------
Traceback (most recent call last):
  File "/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/src/etc/htmldocck.py", line 396, in <module>
    check(sys.argv[1], get_commands(sys.argv[2]))
  File "/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/src/etc/htmldocck.py", line 389, in check
    c.cmd, c.lineno))
RuntimeError: @has check failed at line 42
make[1]: *** [all] Error 1

@bors
Copy link
Collaborator

bors commented Mar 18, 2015

⛄ The build was interrupted to prioritize another pull request.

@bors
Copy link
Collaborator

bors commented Mar 18, 2015

⌛ Testing commit cc27f29 with merge a30341f...

@bors
Copy link
Collaborator

bors commented Mar 18, 2015

⛄ The build was interrupted to prioritize another pull request.

* rustdoc was doubly appending the file name to the path of where to
  generate the source files, meanwhile, the [src] hyperlinks were not
* Added a flag to rustdoc::html::render::clean_srcpath to ignore the
  last path component, i.e. the file name itself to prevent the issue
* This also avoids creating directories with the same name as source
  files, and it makes sure the link to `main.css` is correct as well.
* Added regression tests to ensure the rustdoc heirarchy of rendered
  source files remains consistent

Fixes #23192
@bors
Copy link
Collaborator

bors commented Mar 18, 2015

⌛ Testing commit cc27f29 with merge 10d5cdf...

@ipetkov
Copy link
Contributor Author

ipetkov commented Mar 18, 2015

@huonw @Manishearth d'oh copy paste error in a test file. I was able to test a fix locally and the update should fix things now!

@Manishearth
Copy link
Member

@bors: r=huonw

@bors
Copy link
Collaborator

bors commented Mar 19, 2015

📌 Commit af6cf85 has been approved by huonw

@bors
Copy link
Collaborator

bors commented Mar 19, 2015

⌛ Testing commit af6cf85 with merge 81e2396...

bors added a commit that referenced this pull request Mar 19, 2015
* rustdoc was doubly appending the file name to the path of where to
  generate the source files, meanwhile, the [src] hyperlinks were not
* Added a flag to rustdoc::html::render::clean_srcpath to ignore the
  last path component, i.e. the file name itself to prevent the issue
* This also avoids creating directories with the same name as source
  files, and it makes sure the link to `main.css` is correct as well.

Fixes #23192
@bors bors merged commit af6cf85 into rust-lang:master Mar 19, 2015
@ipetkov ipetkov deleted the rustdoc-src-fix branch March 19, 2015 20:20
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.

The online documentation no longer links to the source
9 participants