Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats committed Jan 24, 2025
1 parent 77164d0 commit 9795738
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 4 deletions.
23 changes: 22 additions & 1 deletion js/html_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface CategoriesPanelCategoryCtx {
active: boolean;
}

export type Page = IndexCtx | AllSymbolsCtx | SymbolPageCtx | Redirect;
export type Page = IndexCtx | AllSymbolsCtx | SymbolPageCtx | Redirect | Search;

export interface PageBase {
kind: "IndexCtx" | "AllSymbolsCtx" | "SymbolPageCtx";
Expand Down Expand Up @@ -60,6 +60,27 @@ export interface Redirect {
path: string;
}

export interface Search {
kind: "search";
path: SearchIndexNode[];
}

export interface SlimKindCtx {
char: string;
kind: string;
title: string;
}

export interface SearchIndexNode {
kind: SlimKindCtx[];
name: string;
file: string;
doc: string;
url: string;
category?: string;
deprecated: boolean;
}

export interface ToCCtx {
usages: UsagesCtx | null;
top_symbols: TopSymbolsCtx | null;
Expand Down
1 change: 1 addition & 0 deletions src/html/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ pub fn generate_search_index(ctx: &GenerateCtx) -> serde_json::Value {
doc_nodes.sort_by(|a, b| a.file.cmp(&b.file));

let search_index = json!({
"kind": "search",
"nodes": doc_nodes
});

Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/html_test__html_doc_files-12.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ source: tests/html_test.rs
expression: files.get(file_name).unwrap()
---
(function () {
window.DENO_DOC_SEARCH_INDEX = {"nodes":[{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Bar","file":".","doc":"","url":"././~/Bar.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foo","file":".","doc":"```ts\nusing time = new FakeTime();\n```","url":"././~/Foo.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foobar","file":".","doc":"","url":"././~/Foobar.html","deprecated":false}]};
window.DENO_DOC_SEARCH_INDEX = {"kind":"search","nodes":[{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Bar","file":".","doc":"","url":"././~/Bar.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foo","file":".","doc":"```ts\nusing time = new FakeTime();\n```","url":"././~/Foo.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foobar","file":".","doc":"","url":"././~/Foobar.html","deprecated":false}]};
})()
4 changes: 2 additions & 2 deletions tests/snapshots/html_test__html_doc_files-2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ expression: files.get(file_name).unwrap()
</div>
</nav>
<div id="searchResults"></div><div id="content">
<main><section >
<div class="space-y-2 flex-1 "><div class="space-y-7" id="module_doc"></div>
<main><section>
<div class="space-y-2 flex-1"><div class="space-y-7" id="module_doc"></div>
</div>
</section>
</main><div class="toc">
Expand Down
45 changes: 45 additions & 0 deletions tests/snapshots/html_test__module_doc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,50 @@ expression: module_docs
}
]
}
},
{
"deprecated": null,
"sections": {
"id": "module_doc",
"docs": null,
"sections": [
{
"header": {
"title": "Variables",
"anchor": {
"id": "Variables"
},
"href": null,
"doc": null
},
"content": {
"kind": "namespace_section",
"content": [
{
"id": "namespace_default",
"anchor": {
"id": "namespace_default"
},
"tags": [],
"doc_node_kind_ctx": [
{
"kind": "Variable",
"char": "v",
"title": "Variable",
"title_lowercase": "variable",
"title_plural": "Variables"
}
],
"href": "../../../../../../../../../../.././/Users/crowlkats/projects/deno/denoland/deno_doc/tests/testdata/multiple/raw.json/~/default.html",
"name": "default",
"docs": null,
"deprecated": false,
"subitems": []
}
]
}
}
]
}
}
]
Loading

0 comments on commit 9795738

Please sign in to comment.