-
Notifications
You must be signed in to change notification settings - Fork 965
Open doc for specific topic #2019
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
Conversation
The fail build is due to clippy errors from master on file that this PR is not touching. |
Regarding the failed build, assuming #2023 passes, I'll merge a fix for the clippy lint issues and you can rebase -- however you do have some formatting problems which I will leave for you. Regarding the idea in general, I quite like it, though I wonder if this ought to depend on |
I have corrected the formatting issues. I think adding |
So my feeling is that we can satisfy both the desire for shorter names, and also using std::prim to distinguish between a primitive and the module as follows:
|
Thought more about it, and reverted to your original suggestion: For anything in a module or bellow, it requires This is follows Rust's own standard, we have to specify |
@dorfsmay Okay that sounds good, I'll give this a go and then think about your original question about how we might test it. |
While I think about that, if you have time, could you rebase/clean up your commit history a bit -- I'd prefer to have nice functional clean commits while reviewing, rather than dealing with formatting commits etc. If you're unsure how to do that, I am prepared to do the trivial option of simply rebasing everything together into one commit for you if you want. |
What are the alternatives to rebasing to a single commit? I'm open... Just trying to understand what the options are, and their pros and cons. |
If I'm doing it for you, I'd do a single commit because it's easiest for me, if you do it, you can clean it up into commits which are nice and clean in the sense that one commit does one thing. I'd rather see a logical progression of functionality rather than a progression of your work if you see what I mean. |
There really is a single functionality, the different commits are just my steps to get there, going back and forth between ideas discussed here, formatting etc... Feel free to squash them into a single commit if you have the time, otherwise I'll try to get to it tomorrow or Sunday. Thanks. |
I like this concept, but the complexity of finding things in the documentation isn't easy to deal with. not least, as a user I'd expect I suggest that it might be simpler (and more orthogonal) to simply take the arguments and pass them in as What do you think of that? i.e.
What do you think? |
I had completely missed the fact that there was a search function on those pages! That's really neat, thanks! I like your idea here, but, I am not finding any way to open a browser to a local file with a query parameter. It works fine with an online URL (http://, https://), but not with a local one. The browsers transform the |
Hmm, I'd tested firefox by |
Squashed into a single commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's at least alloc
to think of, and also the use of OsString
where PathBuf
may be more appropriate. Then we need to finally decide what we're going to do about testing (if anything beyond by-hand on the tier 1 platforms)
src/cli/doc_subpath.rs
Outdated
fn index_html(doc: &DocData, wpath: &Path) -> Option<OsString> { | ||
let indexhtml = wpath.join("index.html"); | ||
match &doc.root.join(&indexhtml).exists() { | ||
true => Some(indexhtml.into_os_string()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you don't make this function return a PathBuf and save the conversions ?
src/cli/doc_subpath.rs
Outdated
for k in keywords { | ||
let filename = &format!("{}.{}.html", k, doc.subtopic); | ||
if entries.contains(&OsString::from(filename)) { | ||
return Ok(dir.join(filename).into_os_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again here, return Result<PathBuf>
and this conversion goes away at least.
src/cli/doc_subpath.rs
Outdated
// topic.split.count cannot be 0 | ||
let subpath_os_str = match topic_vec.len() { | ||
1 => match topic { | ||
"std" | "core" => match index_html(&doc, &work_path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think alloc
is also plausibly something for here?
I have:
Let me know what you think, or if I've missed other cases. I'll start working on a test later today. |
I think that looks pretty good, though it'd be handy if we didn't need the |
Two things regarding the macros:
I have finally added tests. After trying different ideas it looks like the simplest solution is to mock the cases we need to test the same way the default index.html is mocked. I use a separate file in order to be able to use when creating the mock artifacts and and when testing the code behaviour. I tried to keep the format of that file as simple as possible since it will potentially be updated by humans when adding or changing tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two tweaks needed and then I think this might be ready to merge.
src/cli/topical_doc.rs
Outdated
}; | ||
// The path and filename were validated to be existing on the filesystem. | ||
// It should be safe to unwrap, or worth panicking. | ||
Ok(subpath_os_path.into_os_string().into_string().unwrap()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still be tempted to say you should be returning Result<PathBuf>
so that you don't need to do these conversions.
}; | ||
|
||
/************************** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be worth referencing your tests/mock/topical_doc_data.rs
file here to say that if additional functionality is added, it should be added to the tests so that it can be verified. That way we'll keep support for new doc sections properly supported if std
is split up further.
I have added a line in the comment as suggested regarding the test. I also moved the conversion from PathBuf to &str to rustup_mode.rs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I want to have a bit of experimentation to confirm the UX is good, but my gut feeling is that I'll merge it soon (before the next release)
My local testing suggests this is good for MVP, I'm going to merge. |
Feature to allow to open a specific doc eg:
rustup doc core::arch
rustup doc std::never
rustup doc println!
rustup doc fs::read_dir
rustup doc io::Bytes
etc...
This replicates the way pydoc works. I have been using this feature a lot while writing it to the point that I really missed it when deploying a broken version!
This is not 100% finished, I'd like some feedback and understand the appetite for it before putting more time into it. However, I think it is functional enough to be merged as is. Two pieces I want to add:
rustup doc usize
will open the browser to the page for the module "usize", it would be nice to have a way to open the page for the primitive. I'm thinking either add an option like-p
, or append say a "+" sign at the end of the word (e.g.:usize+
) to force the doc for the primitive. I personally prefer the latter, but am looking for feedback...Built and tested on both Rust 1.37 and 1.38.