Skip to content

Add a generator for an "error index" webpage. #25062

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 2 commits into from
May 6, 2015
Merged

Add a generator for an "error index" webpage. #25062

merged 2 commits into from
May 6, 2015

Conversation

michaelsproul
Copy link
Contributor

This PR adds a program which uses the JSON output from #24884 to generate a webpage with descriptions of each diagnostic error.

The page is constructed by hand, with calls to rustdoc's markdown renderers where needed. I opted to generate HTML directly as I think it's more flexible than generating a markdown file and feeding it into the rustdoc executable. I envision adding the ability to filter errors by their properties (description, no description, used, unused), which is infeasible using the whole-file markdown approach due to the need to wrap each error in a <div> (markdown inside tags isn't rendered).

Architecturally, I wasn't sure how to add this generator to the distribution. For the moment I've settled on a separate Rust program in src/etc/ that gets compiled and run by a custom makefile rule. This approach doesn't seem too hackish, but I'm unsure if my usage of makefile variables is correct, particularly the call to rustc (and the LD_LIBRARY_PATH weirdness). Other options I considered were:

  • Integrate the error-index generator into rustdoc so that it gets invoked via a flag and can be built as part of rustdoc.
  • Add the error-index-generator as a "tool" to the TOOLS array, and make use of the facilities for building tools. The main reason I didn't do this was because it seemed like I'd need to add lots of stuff. I'm happy to investigate this further if it's the preferred method.

@rust-highfive
Copy link
Contributor

r? @nikomatsakis

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

@michaelsproul
Copy link
Contributor Author

Here's a preview: http://sproul.io/error-index/error-index.html

@michaelsproul
Copy link
Contributor Author

I think my dependency on the stage 2 compiler is definitely wrong, as running make doc/error-index.html twice results in the whole compiler being re-built 😕

RUSTC_EXE = $(HBIN2_H_$(CFG_BUILD))/rustc
error-index: doc/error-index.html

doc/error-index.html: src/etc/error-index-generator.rs $(RUSTC_EXE) | doc/
Copy link
Member

Choose a reason for hiding this comment

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

I think these dependencies aren't quite right because this needs to depend on libraries like libsyntax and librustdoc from stage2. I think you'll want to depend on CSREQ2_T_$(CFG_BUILD)_H_$(CFG_BUILD) here.

@alexcrichton
Copy link
Member

Nice! Could you upload a preview of what this looks like as well?

@alexcrichton
Copy link
Member

I also think it may be worth looking into TOOLS in the makefiles as that hooks into a lot of our other infrastructure, we just need to be sure to not distribute this tool.

@michaelsproul
Copy link
Contributor Author

There's a preview here: http://sproul.io/error-index/error-index.html

Rust Compiler Error Index

I'll add the panic and look into the tools array now.

@huonw
Copy link
Member

huonw commented May 3, 2015

I wonder if we could take a slightly different route: create a single big markdown file with all the error descriptions and then use a single rustdoc invocation to render that to HTML, benefiting from it inserting headers and footers/setting page metadata/playpen links etc.

(We'd still need a tool to create the markdown file.)

@michaelsproul
Copy link
Contributor Author

@huonw: It's really easy to adjust the generator to do that (and I tried it), but I decided against it because it basically prevents us from adding cool features like filtering and searching. For filtering specifically, I think you need the wrapper divs to group the headers and descriptions together. Then you can hide unused errors for example with a tiny bit of JS:

$(".error-unused").hide();

The wrapper divs are problematic because if you put markdown inside, rustdoc renders it verbatim.

@huonw
Copy link
Member

huonw commented May 3, 2015

Ah, good point.

That could be addressed via some client-side javascript, but it may not be worth it.

@michaelsproul
Copy link
Contributor Author

Now that I'm typing error-index-generator a few more times it feels quite unwieldy... Would err-idx-gen be alright? Or maybe something more general, as I plan to have this tool output info about unused errors and ones in need of descriptions too? error-master, error-tool?

@michaelsproul
Copy link
Contributor Author

Yay! Wrapped my head around the build-system some more and made it a tool.

@michaelsproul
Copy link
Contributor Author

@alexcrichton: I just verified that the error-index-generator binary doesn't get included in the distribution.

@steveklabnik
Copy link
Member

I did something like this before, but made them on individual pages, rather than one big page. I think this is a good start though, 👍

@michaelsproul
Copy link
Contributor Author

@steveklabnik: I hadn't seen your approach but I just read through #16619 and may recycle some of your ideas. I particularly like the form of your error messages, with the summary and the examples 😄

@alexcrichton
Copy link
Member

Nice! The build system changes look great to me. Do you think the errors without descriptions should be listed at all? They do take up quite a bit of space :(

@@ -288,3 +292,9 @@ doc/style/index.html: $(RUSTBOOK_EXE) $(wildcard $(S)/src/doc/style/*.md) | doc/
@$(call E, rustbook: $@)
$(Q)rm -rf doc/style
$(Q)$(RUSTBOOK) build $(S)src/doc/style doc/style

error-index: doc/error-index.html
Copy link
Member

Choose a reason for hiding this comment

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

This rule doesn't seem to be included from anywhere, perhaps it could be added to the docs rule so this is prepared automatically with the rest of the documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! Good point, I'll fix that.

@alexcrichton
Copy link
Member

I also forget how we do this in rustdoc, but rustdoc at least has where when you click on a title it'll highlight it (also when you link to a title it'll highlight what you linked to on the page), but that doesn't seem to be happening here? Perhaps a JS or CSS include is missing from the main rustdoc abilities?

Also, could this generate a markdown file and then use rustdoc to render that instead? That'd help keep it somewhat consistent with the book as well.

@michaelsproul
Copy link
Contributor Author

Including main.css (after rust.css) adds the symbols after the headers and highlights them when clicked. I've updated the preview: http://sproul.io/error-index/error-index.html

Regarding the generated markdown, I don't think it's ideal, as I explained a few comments back: #25062 (comment)

@alexcrichton
Copy link
Member

Including main.css (after rust.css) adds the symbols after the headers and highlights them when clicked

Perfect!

Regarding the generated markdown, I don't think it's ideal, as I explained a few comments back: #25062 (comment)

Wow I read that comment and then totally didn't connect the two together, my mistake!

@michaelsproul
Copy link
Contributor Author

@alexcrichton: Great!

I've added some CSS to hide the errors without descriptions by default.

@michaelsproul
Copy link
Contributor Author

Are we ok to land this @alexcrichton?

@alexcrichton
Copy link
Member

@bors: r+ b9d484f

I believe we are!

steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 5, 2015
…xcrichton

I've added backticks in a few places to ensure correct highlighting in the HTML output (cf rust-lang#25062). 

Other changes include:

* Remove use of `1.` and `2.` separated by a code block as this was being rendered as two separate lists beginning at 1.
* Correct the spelling of successful in two places (from "succesful").

Other changes are a result of reflowing text to stay within the 80 character limit.
steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 5, 2015
…xcrichton

I've added backticks in a few places to ensure correct highlighting in the HTML output (cf rust-lang#25062). 

Other changes include:

* Remove use of `1.` and `2.` separated by a code block as this was being rendered as two separate lists beginning at 1.
* Correct the spelling of successful in two places (from "succesful").

Other changes are a result of reflowing text to stay within the 80 character limit.
@bors
Copy link
Collaborator

bors commented May 6, 2015

⌛ Testing commit b9d484f with merge 016cef9...

bors added a commit that referenced this pull request May 6, 2015
This PR adds a program which uses the JSON output from #24884 to generate a webpage with descriptions of each diagnostic error.

The page is constructed by hand, with calls to `rustdoc`'s markdown renderers where needed. I opted to generate HTML directly as I think it's more flexible than generating a markdown file and feeding it into the `rustdoc` executable. I envision adding the ability to filter errors by their properties (description, no description, used, unused), which is infeasible using the whole-file markdown approach due to the need to wrap each error in a `<div>` (markdown inside tags isn't rendered).

Architecturally, I wasn't sure how to add this generator to the distribution. For the moment I've settled on a separate Rust program in `src/etc/` that gets compiled and run by a custom makefile rule. This approach doesn't seem too hackish, but I'm unsure if my usage of makefile variables is correct, particularly the call to `rustc` (and the `LD_LIBRARY_PATH` weirdness). Other options I considered were:

* Integrate the error-index generator into `rustdoc` so that it gets invoked via a flag and can be built as part of `rustdoc`.
* Add the error-index-generator as a "tool" to the `TOOLS` array, and make use of the facilities for building tools. The main reason I didn't do this was because it seemed like I'd need to add lots of stuff. I'm happy to investigate this further if it's the preferred method.
@bors bors merged commit b9d484f into rust-lang:master May 6, 2015
@michaelsproul michaelsproul deleted the html-error-index branch May 6, 2015 10:14
@Manishearth
Copy link
Member

@michaelsproul
Copy link
Contributor Author

It doesn't have backticks in the source, should be alright as #[main].

@michaelsproul
Copy link
Contributor Author

Fixed in #25331

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.

8 participants