forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#81223 - GuillaumeGomez:generate-redirect-ma…
…p, r=jyn514 [rustdoc] Generate redirect map file Fixes rust-lang#81134. So with this code: ```rust #![crate_name = "foo"] pub use private::Quz; pub use hidden::Bar; mod private { pub struct Quz; } #[doc(hidden)] pub mod hidden { pub struct Bar; } #[macro_export] macro_rules! foo { () => {} } ``` It generates: ```json { "foo/macro.foo!.html": "foo/macro.foo.html", "foo/private/struct.Quz.html": "foo/struct.Quz.html", "foo/hidden/struct.Bar.html": "foo/struct.Bar.html" } ``` Do the pathes look as you expected ```@pietroalbini?``` r? ```@jyn514```
- Loading branch information
Showing
9 changed files
with
150 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-include ../tools.mk | ||
|
||
all: | ||
$(RUSTDOC) -Z unstable-options --generate-redirect-map foo.rs -o "$(TMPDIR)/out" | ||
"$(PYTHON)" validate_json.py "$(TMPDIR)/out" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"foo/macro.foo!.html": "foo/macro.foo.html", | ||
"foo/private/struct.Quz.html": "foo/struct.Quz.html", | ||
"foo/hidden/struct.Bar.html": "foo/struct.Bar.html" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
pub use private::Quz; | ||
pub use hidden::Bar; | ||
|
||
mod private { | ||
pub struct Quz; | ||
} | ||
|
||
#[doc(hidden)] | ||
pub mod hidden { | ||
pub struct Bar; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! foo { | ||
() => {} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/test/run-make-fulldeps/rustdoc-map-file/validate_json.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import sys | ||
import json | ||
|
||
|
||
def find_redirect_map_file(folder, errors): | ||
for root, dirs, files in os.walk(folder): | ||
for name in files: | ||
if not name.endswith("redirect-map.json"): | ||
continue | ||
with open(os.path.join(root, name)) as f: | ||
data = json.load(f) | ||
with open("expected.json") as f: | ||
expected = json.load(f) | ||
for key in expected: | ||
if expected[key] != data.get(key): | ||
errors.append("Expected `{}` for key `{}`, found: `{}`".format( | ||
expected[key], key, data.get(key))) | ||
else: | ||
del data[key] | ||
for key in data: | ||
errors.append("Extra data not expected: key: `{}`, data: `{}`".format( | ||
key, data[key])) | ||
return True | ||
return False | ||
|
||
|
||
if len(sys.argv) != 2: | ||
print("Expected doc directory to check!") | ||
sys.exit(1) | ||
|
||
errors = [] | ||
if not find_redirect_map_file(sys.argv[1], errors): | ||
print("Didn't find the map file in `{}`...".format(sys.argv[1])) | ||
sys.exit(1) | ||
for err in errors: | ||
print("=> {}".format(err)) | ||
if len(errors) != 0: | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// compile-flags: -Z unstable-options --generate-redirect-map | ||
|
||
#![crate_name = "foo"] | ||
|
||
// @!has foo/redirect-map.json | ||
pub struct Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// compile-flags: -Z unstable-options --generate-redirect-map | ||
|
||
#![crate_name = "foo"] | ||
|
||
// @!has foo/private/struct.Quz.html | ||
// @!has foo/hidden/struct.Bar.html | ||
// @has foo/redirect-map.json | ||
pub use private::Quz; | ||
pub use hidden::Bar; | ||
|
||
mod private { | ||
pub struct Quz; | ||
} | ||
|
||
#[doc(hidden)] | ||
pub mod hidden { | ||
pub struct Bar; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! foo { | ||
() => {} | ||
} |