Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRustdoc needs to handle conditional compilation somehow #1998
Comments
This comment has been minimized.
This comment has been minimized.
|
I think the latter case is probably best, yes. Collapse-same-name is a bit of a kludge but not entirely unexpected. |
ghost
assigned
brson
Apr 13, 2012
This comment has been minimized.
This comment has been minimized.
|
Not backwards-compatible. Nominating for milestone 4, well-covered (having documentation tools work the way we expect is helpful in making sure the documentation covers everything...) |
This comment has been minimized.
This comment has been minimized.
|
doc-coverage can be assured elsewhere, but this is embarrassing. should be fixed before production ready. |
This comment has been minimized.
This comment has been minimized.
|
accepted for production-ready milestone |
This comment has been minimized.
This comment has been minimized.
|
Nothing new to say except to link to #5413. |
This comment has been minimized.
This comment has been minimized.
|
This is not yet fixed by rustdoc_ng, and requires a bit of thought. |
This comment has been minimized.
This comment has been minimized.
|
This is a hard problem with no good solution. If I use the AST before configuration, I can't have any hyperlinking for those items. Is that worth it? |
This comment has been minimized.
This comment has been minimized.
|
Low, no milestone |
This comment has been minimized.
This comment has been minimized.
|
My current thinking:
Then, later, when cleaning, check if the item's nodeid is in the sidetable of cfg'd things. If so, add them to a vec of "alternatives" in the item, cleaning each. This depends on:
When rendered, we'd have a list of "alternative definitions", listing the cfg's that would have enabled them. This of course doesn't handle things that are actually conditionally enabled/disabled, just things that are defined multiple times. |
This comment has been minimized.
This comment has been minimized.
|
I'm not sure about AST renumberings off the top of my head. |
thestinger
removed
the
I-completion
label
Sep 16, 2014
klutzy
referenced this issue
Apr 21, 2015
Closed
std::os::windows missing on http://doc.rust-lang.org/nightly/std/os/ #24658
This comment has been minimized.
This comment has been minimized.
KostaCitrix
commented
Jul 13, 2015
|
Please fix. It's really confusing to see missing/wrong documentation if working on non-linux. This is one more 'gotcha' that you need to know, so this makes it harder to start working with rust on non-linux platform. Thank you for you consideration! :) |
This comment has been minimized.
This comment has been minimized.
|
@KostaCitrix this is a challenging issue to fix and we're all aware of the usability impacts this has. Demanding "please fix" doesn't really help solve the technical issues. |
This comment has been minimized.
This comment has been minimized.
|
This is potentially less of a problem now that docs are installed with the distribution. It does seem, though, like this fact isn't particularly well known to newcomers. |
This comment has been minimized.
This comment has been minimized.
|
In some ways, but it still doesn't lay out a good welcome mat to those who aren't using Linux. |
This comment has been minimized.
This comment has been minimized.
|
I ran out of fingers to count the number of times I've seen people not find Windows specific extension traits because the online docs were linux-only. |
This comment has been minimized.
This comment has been minimized.
|
How about building docs on all three supported platforms and uploading to doc.rust-lang.org/nightly/windows, nightly/linux, etc? Of course this doesn't solve the general problem of rustdoc and conditional compilation.
|
This comment has been minimized.
This comment has been minimized.
|
One potential problem with trying to do the AST approach is if the same function/type is defined for multiple platforms with different doc comments, which doc comment do we show for the item? Or maybe even more importantly, same function with different types, or same type with different public fields? One possible solution might be to add a selector somewhere on the page that lets you pick the platform you wish to view, and it would use that to show the correct documentation/types/fields. It could still show AST elements that aren't available on that platform but perhaps greyed out, to indicate that they're not available. Another solution is to do what @tomjakubowski suggested and just upload docs for each platform to a different path. The main rustdoc UI could then still have the selector, which changes the URL to view that platform's documentation (and sets a cookie that is used by the non-platform-specific documentation path to automatically jump to the platform-specific path). One downside to this is every documentation URL that people share would then be a platform-specific URL. |
This comment has been minimized.
This comment has been minimized.
In this case, I think we should emit a warning (that can be made into an error via a command line flag, to make this useful for CI or local testing, but still preserves compatibility) and just pick one (maybe the native one for compatibility). If only one of these item has docs, this is a non-issue (which should be the preferred way to document this IMO).
I'm not sure about what a type means to Rustdoc, but I don't think it uses type information. This would mean that at least type aliases are handled automatically: The type can be something like Now all remaining cases should be rare, so we could emit a warning for them as well. Which item we actually pick... no idea, maybe the same item we would pick today (like above). I could also imagine solving these 2 issues by just adding docs for both items and marking them with their cfg attribute (something that would be nice in any case).
http://doc.rust-lang.org/libc is apparently doing that already, but it's not the best from a usability perspective, and I don't think |
kamalmarhubi
referenced this issue
Feb 19, 2016
Closed
Documentation lacks modules that depend on compile-time features. #206
mitaa
referenced this issue
Apr 1, 2016
Closed
`rustdoc` or `cargo doc` should pass a special `--cfg doc` flag #834
This comment has been minimized.
This comment has been minimized.
|
Note that this also has an effect on the cc @nrc |
This comment has been minimized.
This comment has been minimized.
|
crates.fyi is another solution to this issue /cc @onur |
This comment has been minimized.
This comment has been minimized.
|
I don't think there is a good answer to this in rustdoc itself. The better answer (which Steve hints at) is that we should build and host docs for every platform, not just Linux. |
This comment has been minimized.
This comment has been minimized.
|
Tell me when winapi's docs are finally up on crates.fyi |
This comment has been minimized.
This comment has been minimized.
|
As an update to this, crates.fyi is now docs.rs and has documentation for all tier 1 platforms. It even has winapi docs. |
steveklabnik
referenced this issue
Nov 18, 2016
Closed
rustdoc: Generate docs for all platforms at once #3300
This comment has been minimized.
This comment has been minimized.
valarauca
commented
Nov 23, 2016
|
In the short term isn't this solved with #[cfg(any(feature = "doc", target_yada="foobar"))] |
steveklabnik
referenced this issue
Jan 31, 2017
Closed
Generate documentation for all platforms by default #39423
steveklabnik
added
the
T-tools
label
Mar 9, 2017
ollie27
referenced this issue
May 11, 2017
Open
"[src]" link points to nightly std instead of crate's source code #41903
steveklabnik
added
T-dev-tools
and removed
T-tools
labels
May 18, 2017
Mark-Simulacrum
referenced this issue
Jun 23, 2017
Closed
Indicate when an item or impl depends on a feature #35903
This comment has been minimized.
This comment has been minimized.
|
In addition to simply unifying different features and platforms in the docs, there should be a clear visual indicator that some API is available only in the presence of some particular feature – this is especially important for features, which unlike platforms are easily toggleable but hard to discover. |
Mark-Simulacrum
added
the
C-feature-request
label
Jul 19, 2017
kennytm
referenced this issue
Jul 20, 2017
Merged
Expose all OS-specific modules in libstd doc. #43348
This comment has been minimized.
This comment has been minimized.
|
I've thought a bit about this recently, so i'll brain-dump into this issue in case anyone else is interested: I call this the "holy grail" of rustdoc, because all the ways i know of to scrape a crate for docs will hit against some kind of fundamental limitation. Using the compiler itself (like rustdoc currently does) or using Side-stepping the compiler and reading the raw source code yourself (i.e. going through To do this with the do-it-yourself / My idea for surfacing these things in docs is to duplicate the item for each
Or among the trait implementations for
...on the other hand, this doesn't take into account doing something like |
bors
added a commit
that referenced
this issue
Aug 10, 2017
bors
added a commit
that referenced
this issue
Aug 11, 2017
bors
added a commit
that referenced
this issue
Aug 13, 2017
Nemo157
referenced this issue
Oct 3, 2017
Closed
Render cfg(feature) requirements in documentation #44994
QuietMisdreavus
referenced this issue
Aug 14, 2018
Merged
set cfg(rustdoc) when rustdoc is running on a crate #53076
This comment has been minimized.
This comment has been minimized.
|
Triage: this is still the holy grail. |
brson commentedMar 16, 2012
We have some functions that are reimplemented per architecture, with docs only on one implementation. Rustdoc should ideally be able to merge these docs.
More seriously though a bunch of our libc hierarchy can't be viewed because it's conditionally compiled and the docs are built on linux.
Probably rustdoc should extract its documentation before pruning the AST for conditional compilation, collapse things with the same name into a single document, then run resolve.