|
2 | 2 | // the sidebar and in the module. |
3 | 3 |
|
4 | 4 | go-to: "file://" + |DOC_PATH| + "/test_docs/macro.b.html" |
5 | | -// It should be present twice in the sidebar. |
6 | | -assert-count: ("#rustdoc-modnav a[href='macro.attr_macro.html']", 2) |
7 | | -assert-count: ("//*[@id='rustdoc-modnav']//a[text()='attr_macro']", 2) |
8 | 5 | // We check that the current item in the sidebar is the correct one. |
9 | 6 | assert-text: ("#rustdoc-modnav .block.macro .current", "b") |
10 | 7 |
|
11 | | -// We now go to the attribute macro page. |
12 | | -click: "#rustdoc-modnav a[href='macro.attr_macro.html']" |
13 | | -// It should be present twice in the sidebar. |
14 | | -assert-count: ("#rustdoc-modnav a[href='macro.attr_macro.html']", 2) |
15 | | -assert-count: ("//*[@id='rustdoc-modnav']//a[text()='attr_macro']", 2) |
16 | | -// We check that the current item is the "attr_macro". |
17 | | -assert-text: ("#rustdoc-modnav .block.macro .current", "attr_macro") |
18 | | -// Since the item is present twice in the sidebar, we should have two "current" items. |
19 | | -assert-count: ("#rustdoc-modnav .current", 2) |
20 | | -// We check it has the expected information. |
21 | | -assert-text: ("h3.macro-info", "ⓘ This is an attribute/function macro") |
| 8 | +define-function: ( |
| 9 | + "check_macro", |
| 10 | + [name, info], |
| 11 | + block { |
| 12 | + // It should be present twice in the sidebar. |
| 13 | + assert-count: ("#rustdoc-modnav a[href='macro." + |name| + ".html']", 2) |
| 14 | + assert-count: ("//*[@id='rustdoc-modnav']//a[text()='" + |name| + "']", 2) |
| 15 | + |
| 16 | + // We now go to the macro page. |
| 17 | + click: "#rustdoc-modnav a[href='macro." + |name| + ".html']" |
| 18 | + // It should be present twice in the sidebar. |
| 19 | + assert-count: ("#rustdoc-modnav a[href='macro." + |name| + ".html']", 2) |
| 20 | + assert-count: ("//*[@id='rustdoc-modnav']//a[text()='" + |name| + "']", 2) |
| 21 | + // We check that the current item is the macro. |
| 22 | + assert-text: ("#rustdoc-modnav .block.macro .current", |name|) |
| 23 | + // Since the item is present twice in the sidebar, we should have two "current" items. |
| 24 | + assert-count: ("#rustdoc-modnav .current", 2) |
| 25 | + // We check it has the expected information. |
| 26 | + assert-text: ("h3.macro-info", "ⓘ This is " + |info| + "/function macro") |
| 27 | + } |
| 28 | +) |
| 29 | + |
| 30 | +call-function: ("check_macro", {"name": "attr_macro", "info": "an attribute"}) |
| 31 | +call-function: ("check_macro", {"name": "derive_macro", "info": "a derive"}) |
| 32 | + |
| 33 | +define-function: ( |
| 34 | + "crate_page", |
| 35 | + [name, section_id], |
| 36 | + block { |
| 37 | + // It should be only present twice. |
| 38 | + assert-count: ("#main-content a[href='macro." + |name| + ".html']", 2) |
| 39 | + // First in the "Macros" section. |
| 40 | + assert-text: ("#macros + .item-table a[href='macro." + |name| + ".html']", |name|) |
| 41 | + // Then in the other macro section. |
| 42 | + assert-text: ( |
| 43 | + "#" + |section_id| + " + .item-table a[href='macro." + |name| + ".html']", |
| 44 | + |name|, |
| 45 | + ) |
| 46 | + } |
| 47 | +) |
22 | 48 |
|
23 | 49 | // Now we check it's correctly listed in the crate page. |
24 | 50 | go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" |
25 | | -// It should be only present twice. |
26 | | -assert-count: ("#main-content a[href='macro.attr_macro.html']", 2) |
27 | | -// First in the "Macros" section. |
28 | | -assert-text: ("#macros + .item-table a[href='macro.attr_macro.html']", "attr_macro") |
29 | | -// Then in the "Attribute Macros" section. |
30 | | -assert-text: ("#attribute-macros + .item-table a[href='macro.attr_macro.html']", "attr_macro") |
| 51 | +call-function: ("crate_page", {"name": "attr_macro", "section_id": "attribute-macros"}) |
| 52 | +call-function: ("crate_page", {"name": "derive_macro", "section_id": "derives"}) |
| 53 | +// We also check we don't have duplicated sections. |
| 54 | +assert-count: ("//*[@id='main-content']/h2[text()='Attribute Macros']", 1) |
| 55 | +assert-count: ("//*[@id='main-content']/h2[text()='Derive Macros']", 1) |
| 56 | + |
| 57 | +define-function: ( |
| 58 | + "all_items_page", |
| 59 | + [name, section_id], |
| 60 | + block { |
| 61 | + // It should be only present twice. |
| 62 | + assert-count: ("#main-content a[href='macro." + |name| + ".html']", 2) |
| 63 | + // First in the "Macros" section. |
| 64 | + assert-text: ("#macros + .all-items a[href='macro." + |name| + ".html']", |name|) |
| 65 | + // Then in the "Attribute Macros" section. |
| 66 | + assert-text: ( |
| 67 | + "#" + |section_id| + " + .all-items a[href='macro." + |name| + ".html']", |
| 68 | + |name|, |
| 69 | + ) |
| 70 | + } |
| 71 | +) |
31 | 72 |
|
32 | 73 | // And finally we check it's correctly listed in the "all items" page. |
33 | 74 | go-to: "file://" + |DOC_PATH| + "/test_docs/all.html" |
34 | | -// It should be only present twice. |
35 | | -assert-count: ("#main-content a[href='macro.attr_macro.html']", 2) |
36 | | -// First in the "Macros" section. |
37 | | -assert-text: ("#macros + .all-items a[href='macro.attr_macro.html']", "attr_macro") |
38 | | -// Then in the "Attribute Macros" section. |
39 | | -assert-text: ("#attribute-macros + .all-items a[href='macro.attr_macro.html']", "attr_macro") |
| 75 | +call-function: ("all_items_page", {"name": "attr_macro", "section_id": "attribute-macros"}) |
| 76 | +call-function: ("all_items_page", {"name": "derive_macro", "section_id": "derives"}) |
0 commit comments