-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make paths displed on left nav bar if duplicated (#1592)
- Loading branch information
Showing
19 changed files
with
331 additions
and
8 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
19 changes: 19 additions & 0 deletions
19
extensions/scarb-doc/tests/data/duplicated_item_names/book.toml
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,19 @@ | ||
[book] | ||
authors = ["<unknown>"] | ||
language = "en" | ||
multilingual = false | ||
src = "src" | ||
title = "hello_world - Cairo" | ||
|
||
[output.html] | ||
no-section-label = true | ||
|
||
[output.html.playground] | ||
runnable = false | ||
|
||
[output.html.fold] | ||
enable = true | ||
level = 0 | ||
|
||
[output.html.code.hidelines] | ||
cairo = "#" |
30 changes: 30 additions & 0 deletions
30
extensions/scarb-doc/tests/data/duplicated_item_names/src/SUMMARY.md
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,30 @@ | ||
# Summary | ||
|
||
- [Modules](./modules.md) | ||
|
||
- [hello_world](./hello_world.md) | ||
|
||
- [sub_module](./hello_world-sub_module.md) | ||
|
||
- [Free functions](./free_functions.md) | ||
|
||
- [main](./hello_world-main.md) | ||
|
||
- [unique_function_name](./hello_world-unique_function_name.md) | ||
|
||
- [duplicated_function_name](./hello_world-duplicated_function_name.md) | ||
|
||
- [sub_module::duplicated_function_name](./hello_world-sub_module-duplicated_function_name.md) | ||
|
||
- [Enums](./enums.md) | ||
|
||
- [DuplicatedEnumName](./hello_world-DuplicatedEnumName.md) | ||
|
||
- [sub_module::DuplicatedEnumName](./hello_world-sub_module-DuplicatedEnumName.md) | ||
|
||
- [Traits](./traits.md) | ||
|
||
- [DuplicatedTraitName](./hello_world-DuplicatedTraitName.md) | ||
|
||
- [sub_module::DuplicatedTraitName](./hello_world-sub_module-DuplicatedTraitName.md) | ||
|
6 changes: 6 additions & 0 deletions
6
extensions/scarb-doc/tests/data/duplicated_item_names/src/enums.md
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 @@ | ||
# Enums | ||
|
||
- [DuplicatedEnumName](./hello_world-DuplicatedEnumName.md) | ||
|
||
- [sub_module::DuplicatedEnumName](./hello_world-sub_module-DuplicatedEnumName.md) | ||
|
10 changes: 10 additions & 0 deletions
10
extensions/scarb-doc/tests/data/duplicated_item_names/src/free_functions.md
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,10 @@ | ||
# Free functions | ||
|
||
- [main](./hello_world-main.md) | ||
|
||
- [unique_function_name](./hello_world-unique_function_name.md) | ||
|
||
- [duplicated_function_name](./hello_world-duplicated_function_name.md) | ||
|
||
- [sub_module::duplicated_function_name](./hello_world-sub_module-duplicated_function_name.md) | ||
|
4 changes: 4 additions & 0 deletions
4
...carb-doc/tests/data/duplicated_item_names/src/hello_world-DuplicatedEnumName.md
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,4 @@ | ||
# DuplicatedEnumName | ||
|
||
Fully qualified path: `hello_world::DuplicatedEnumName` | ||
|
8 changes: 8 additions & 0 deletions
8
...arb-doc/tests/data/duplicated_item_names/src/hello_world-DuplicatedTraitName.md
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,8 @@ | ||
# DuplicatedTraitName | ||
|
||
Fully qualified path: `hello_world::DuplicatedTraitName` | ||
|
||
```rust | ||
trait DuplicatedTraitName | ||
``` | ||
|
8 changes: 8 additions & 0 deletions
8
...oc/tests/data/duplicated_item_names/src/hello_world-duplicated_function_name.md
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,8 @@ | ||
# duplicated_function_name | ||
|
||
Fully qualified path: `hello_world::duplicated_function_name` | ||
|
||
```rust | ||
fn duplicated_function_name() | ||
``` | ||
|
8 changes: 8 additions & 0 deletions
8
extensions/scarb-doc/tests/data/duplicated_item_names/src/hello_world-main.md
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,8 @@ | ||
# main | ||
|
||
Fully qualified path: `hello_world::main` | ||
|
||
```rust | ||
fn main() | ||
``` | ||
|
4 changes: 4 additions & 0 deletions
4
...sts/data/duplicated_item_names/src/hello_world-sub_module-DuplicatedEnumName.md
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,4 @@ | ||
# DuplicatedEnumName | ||
|
||
Fully qualified path: `hello_world::sub_module::DuplicatedEnumName` | ||
|
8 changes: 8 additions & 0 deletions
8
...ts/data/duplicated_item_names/src/hello_world-sub_module-DuplicatedTraitName.md
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,8 @@ | ||
# DuplicatedTraitName | ||
|
||
Fully qualified path: `hello_world::sub_module::DuplicatedTraitName` | ||
|
||
```rust | ||
trait DuplicatedTraitName | ||
``` | ||
|
8 changes: 8 additions & 0 deletions
8
...ta/duplicated_item_names/src/hello_world-sub_module-duplicated_function_name.md
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,8 @@ | ||
# duplicated_function_name | ||
|
||
Fully qualified path: `hello_world::sub_module::duplicated_function_name` | ||
|
||
```rust | ||
fn duplicated_function_name() | ||
``` | ||
|
16 changes: 16 additions & 0 deletions
16
...nsions/scarb-doc/tests/data/duplicated_item_names/src/hello_world-sub_module.md
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 @@ | ||
# sub_module | ||
|
||
Fully qualified path: `hello_world::sub_module` | ||
|
||
## Free functions | ||
|
||
- [duplicated_function_name](./hello_world-sub_module-duplicated_function_name.md) | ||
|
||
## Enums | ||
|
||
- [DuplicatedEnumName](./hello_world-sub_module-DuplicatedEnumName.md) | ||
|
||
## Traits | ||
|
||
- [DuplicatedTraitName](./hello_world-sub_module-DuplicatedTraitName.md) | ||
|
8 changes: 8 additions & 0 deletions
8
...rb-doc/tests/data/duplicated_item_names/src/hello_world-unique_function_name.md
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,8 @@ | ||
# unique_function_name | ||
|
||
Fully qualified path: `hello_world::unique_function_name` | ||
|
||
```rust | ||
fn unique_function_name() | ||
``` | ||
|
24 changes: 24 additions & 0 deletions
24
extensions/scarb-doc/tests/data/duplicated_item_names/src/hello_world.md
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,24 @@ | ||
# hello_world | ||
|
||
Fully qualified path: `hello_world` | ||
|
||
## Modules | ||
|
||
- [sub_module](./hello_world-sub_module.md) | ||
|
||
## Free functions | ||
|
||
- [main](./hello_world-main.md) | ||
|
||
- [unique_function_name](./hello_world-unique_function_name.md) | ||
|
||
- [duplicated_function_name](./hello_world-duplicated_function_name.md) | ||
|
||
## Enums | ||
|
||
- [DuplicatedEnumName](./hello_world-DuplicatedEnumName.md) | ||
|
||
## Traits | ||
|
||
- [DuplicatedTraitName](./hello_world-DuplicatedTraitName.md) | ||
|
6 changes: 6 additions & 0 deletions
6
extensions/scarb-doc/tests/data/duplicated_item_names/src/modules.md
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 @@ | ||
# Modules | ||
|
||
- [hello_world](./hello_world.md) | ||
|
||
- [sub_module](./hello_world-sub_module.md) | ||
|
6 changes: 6 additions & 0 deletions
6
extensions/scarb-doc/tests/data/duplicated_item_names/src/traits.md
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 @@ | ||
# Traits | ||
|
||
- [DuplicatedTraitName](./hello_world-DuplicatedTraitName.md) | ||
|
||
- [sub_module::DuplicatedTraitName](./hello_world-sub_module-DuplicatedTraitName.md) | ||
|
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,73 @@ | ||
use assert_fs::TempDir; | ||
use indoc::indoc; | ||
use scarb_test_support::command::Scarb; | ||
use scarb_test_support::project_builder::ProjectBuilder; | ||
|
||
pub mod markdown_target; | ||
use markdown_target::MarkdownTargetChecker; | ||
|
||
#[test] | ||
fn test_duplicated_items_names() { | ||
let root_dir = TempDir::new().unwrap(); | ||
|
||
ProjectBuilder::start() | ||
.name("hello_world") | ||
.lib_cairo(indoc! {r#" | ||
mod sub_module; | ||
fn main() { | ||
println!("hellow") | ||
} | ||
fn unique_function_name() { | ||
// pass | ||
} | ||
fn duplicated_function_name() { | ||
// pass | ||
} | ||
enum DuplicatedEnumName { | ||
// pass | ||
} | ||
trait DuplicatedTraitName { | ||
// pass | ||
} | ||
"#}) | ||
.src( | ||
"src/sub_module.cairo", | ||
indoc! {r#" | ||
fn duplicated_function_name() { | ||
// pass | ||
} | ||
enum DuplicatedEnumName { | ||
// pass | ||
} | ||
trait DuplicatedTraitName { | ||
// pass | ||
} | ||
"#}, | ||
) | ||
.build(&root_dir); | ||
|
||
Scarb::quick_snapbox() | ||
.arg("doc") | ||
.args(["--document-private-items"]) | ||
.current_dir(&root_dir) | ||
.assert() | ||
.success(); | ||
|
||
MarkdownTargetChecker::default() | ||
.actual( | ||
root_dir | ||
.path() | ||
.join("target/doc/hello_world") | ||
.to_str() | ||
.unwrap(), | ||
) | ||
.expected("tests/data/duplicated_item_names") | ||
.assert_all_files_match(); | ||
} |