rust/src
Guillaume Gomez 68d3cfac47
Rollup merge of #101166 - GuillaumeGomez:error-index-mdbook, r=notriddle
Generate error index with mdbook instead of raw HTML pages

This is a follow-up of https://github.com/rust-lang/rust/pull/100922.

This comes from a remark from ````@estebank```` who said that the search was a nice thing on the previous version and that it wasn't possible anymore. An easy way to come around this limitation was to use `mdbook`, which is what I did here.

Now some explanations on the code. I'll explain how I developed this and why I reached this solution. First I did it very basically by simply setting the source directory and the output directory, generated a `SUMMARY.md` manually which listed all error codes and that was it. Two problems arose from this:
 1. A lot of new HTML files were generated at the top level
 2. An `index.html` file was generated at the top-level (the summary in short).

So for `1.`, it's not great to have too many files at the top-level as it could create file conflicts more easily. And for `2.`, this is actually a huge issue because <doc.rust-lang.org> generates an `index.html` file with a links to a few different resources, so it should never be overwritten. <s>Unfortunately, `mdbook` **always** generates an `index.html` file so the only solution I could see (except for sending them a contribution, I'll maybe do that later) was to temporaly move a potentially existing `index.html` file and then puts it back once done. For this last part, to ensure that we don't return *before* it has been put back, I wrapped the `mdbook` generation code inside `render_html_inner` which is called from `render_html` which in turn handle the "save" of `index.html`.</s>

EDIT: `mdbook` completely deletes ALL the content in the target directory so I instead generate into a sub directory and then I move the files to the real target directory.

To keep compatibility with the old version, I also put the `<script>` ````@notriddle```` nicely provided in the previous PR only into the `error-index.html` file to prevent unneeded repetition. I didn't use `mdbook` `additional-js` option because the JS is included at the end of all HTML files, which we don't want for two reasons:
 1. It's slow.
 2. We only want it to be run in `error-index.html` (even if we also ensure in the JS itself too!).

<s>Now the last part: why we generate the summary twice. We actually generate it once to tell `mdbook` what the book will look like and a second time because a create a new chapter content which will actually list all the error codes (with the updated paths).</s>

EDIT: I removed the need for two summaries.

You can test it [here](https://rustdoc.crud.net/imperio/error-index-mdbook/error-index.html).

r? ````@notriddle````
2022-09-02 11:34:51 +02:00
..
bootstrap Rollup merge of #101166 - GuillaumeGomez:error-index-mdbook, r=notriddle 2022-09-02 11:34:51 +02:00
ci Auto merge of #100935 - cuviper:upgrade-android-ci, r=Mark-Simulacrum 2022-09-02 05:32:57 +00:00
doc Rollup merge of #101271 - QuinnPainter:patch-1, r=Dylan-DPC 2022-09-01 21:37:17 +02:00
etc Fix a bunch of typo 2022-08-31 18:24:55 +08:00
librustdoc Rollup merge of #101292 - rust-lang:notriddle/rustdoc-table-first-child, r=GuillaumeGomez 2022-09-01 21:37:23 +02:00
llvm-project@e3be3f64ec Patch lld for older toolchains 2022-08-11 15:51:59 -07:00
rustdoc-json-types Rollup merge of #100335 - aDotInTheVoid:rdj-resolved-path, r=GuillaumeGomez 2022-08-13 21:06:48 -07:00
test Rollup merge of #100827 - JakobDegen:better-tests, r=wesleywiser 2022-09-02 11:34:50 +02:00
tools Rollup merge of #101166 - GuillaumeGomez:error-index-mdbook, r=notriddle 2022-09-02 11:34:51 +02:00
README.md Sunset RLS 2022-08-27 21:36:08 -07:00
stage0.json Bump stage0 2022-08-29 19:30:11 +02:00
version Bump to 1.65.0 2022-08-05 11:32:46 -04:00

This directory contains the source code of the rust project, including:

  • The test suite
  • The bootstrapping build system
  • Various submodules for tools, like cargo, miri, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.