diff --git a/CHANGELOG.md b/CHANGELOG.md index 165382f49..c93b4bbd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Fixed an issue where links in packages mode would be resolved incorrectly, #2680. - `@link` tags to symbols which are not included in the documentation will produce invalid link warnings again, #2681. - Fixed handling of `@param` tags on comments attached to function callback parameters, #2683. +- The `alphabetical` and `alphabetical-ignoring-documents` sort options now use `localeCompare` to sort, #2684. ## v0.26.6 (2024-08-18) diff --git a/src/lib/output/events.ts b/src/lib/output/events.ts index 8431db0ad..44e6b0b3a 100644 --- a/src/lib/output/events.ts +++ b/src/lib/output/events.ts @@ -61,7 +61,7 @@ export class RendererEvent { public createPageEvent( mapping: UrlMapping, ): [RenderTemplate>, PageEvent] { - const event = new PageEvent(PageEvent.BEGIN, mapping.model); + const event = new PageEvent(mapping.model); event.project = this.project; event.url = mapping.url; event.filename = Path.join(this.outputDirectory, mapping.url); @@ -84,7 +84,7 @@ export interface PageHeading { * @see {@link Renderer.EVENT_BEGIN_PAGE} * @see {@link Renderer.EVENT_END_PAGE} */ -export class PageEvent extends Event { +export class PageEvent { /** * The project the renderer is currently processing. */ @@ -152,9 +152,15 @@ export class PageEvent extends Event { */ static readonly END = "endPage"; - constructor(name: string, model: Model) { - super(name); - this.model = model; + constructor(model: Model); + /** @deprecated use the single constructor arg instead, will be removed in 0.27 */ + constructor(name: string, model: Model); + constructor(nameOrModel: string | Model, model?: Model) { + if (typeof nameOrModel === "string") { + this.model = model!; + } else { + this.model = nameOrModel as Model; + } } } diff --git a/src/lib/output/renderer.ts b/src/lib/output/renderer.ts index c64020742..118e010cb 100644 --- a/src/lib/output/renderer.ts +++ b/src/lib/output/renderer.ts @@ -143,13 +143,11 @@ export interface RendererEvents { * * * {@link Renderer.EVENT_BEGIN_PAGE}
* Triggered before a document will be rendered. The listener receives an instance of - * {@link PageEvent}. By calling {@link PageEvent.preventDefault} the generation of the - * document can be canceled. + * {@link PageEvent}. * * * {@link Renderer.EVENT_END_PAGE}
* Triggered after a document has been rendered, just before it is written to disc. The - * listener receives an instance of {@link PageEvent}. When calling - * {@link PageEvent.preventDefault} the the document will not be saved to disc. + * listener receives an instance of {@link PageEvent}. * * * {@link Renderer.EVENT_END}
* Triggered after the renderer has written all documents. The listener receives diff --git a/src/lib/utils/sort.ts b/src/lib/utils/sort.ts index 8fda9f003..7583dad5c 100644 --- a/src/lib/utils/sort.ts +++ b/src/lib/utils/sort.ts @@ -62,7 +62,7 @@ const sorts: Record< return false; }, alphabetical(a, b) { - return a.name < b.name; + return a.name.localeCompare(b.name) < 0; }, "alphabetical-ignoring-documents"(a, b) { if ( @@ -71,7 +71,7 @@ const sorts: Record< ) { return false; } - return a.name < b.name; + return a.name.localeCompare(b.name) < 0; }, "enum-value-ascending"(a, b) { if ( diff --git a/src/test/converter/exports/specs.json b/src/test/converter/exports/specs.json index e888ba424..6558d692a 100644 --- a/src/test/converter/exports/specs.json +++ b/src/test/converter/exports/specs.json @@ -12,6 +12,62 @@ "kind": 2, "flags": {}, "children": [ + { + "id": 44, + "name": "a", + "variant": "reference", + "kind": 4194304, + "flags": {}, + "sources": [ + { + "fileName": "mod.ts", + "line": 8, + "character": 13, + "url": "typedoc://mod.ts#L8" + } + ], + "target": 30 + }, + { + "id": 45, + "name": "b", + "variant": "reference", + "kind": 4194304, + "flags": {}, + "comment": { + "summary": [ + { + "kind": "text", + "text": "An export of a local under a different name." + } + ] + }, + "sources": [ + { + "fileName": "mod.ts", + "line": 13, + "character": 14, + "url": "typedoc://mod.ts#L13" + } + ], + "target": 31 + }, + { + "id": 40, + "name": "c", + "variant": "reference", + "kind": 4194304, + "flags": {}, + "sources": [ + { + "fileName": "export.ts", + "line": 5, + "character": 14, + "url": "typedoc://export.ts#L5" + } + ], + "target": 30 + }, { "id": 48, "name": "GH1453Helper", @@ -100,62 +156,6 @@ ], "target": 34 }, - { - "id": 44, - "name": "a", - "variant": "reference", - "kind": 4194304, - "flags": {}, - "sources": [ - { - "fileName": "mod.ts", - "line": 8, - "character": 13, - "url": "typedoc://mod.ts#L8" - } - ], - "target": 30 - }, - { - "id": 45, - "name": "b", - "variant": "reference", - "kind": 4194304, - "flags": {}, - "comment": { - "summary": [ - { - "kind": "text", - "text": "An export of a local under a different name." - } - ] - }, - "sources": [ - { - "fileName": "mod.ts", - "line": 13, - "character": 14, - "url": "typedoc://mod.ts#L13" - } - ], - "target": 31 - }, - { - "id": 40, - "name": "c", - "variant": "reference", - "kind": 4194304, - "flags": {}, - "sources": [ - { - "fileName": "export.ts", - "line": 5, - "character": 14, - "url": "typedoc://export.ts#L5" - } - ], - "target": 30 - }, { "id": 20, "name": "GH1453", @@ -419,14 +419,14 @@ { "title": "References", "children": [ + 44, + 45, + 40, 48, 41, 43, 42, - 47, - 44, - 45, - 40 + 47 ] }, { @@ -704,22 +704,6 @@ "kind": 2, "flags": {}, "children": [ - { - "id": 34, - "name": "ThisModule", - "variant": "reference", - "kind": 4194304, - "flags": {}, - "sources": [ - { - "fileName": "mod.ts", - "line": 40, - "character": 12, - "url": "typedoc://mod.ts#L40" - } - ], - "target": 29 - }, { "id": 31, "name": "b", @@ -768,6 +752,22 @@ ], "target": 30 }, + { + "id": 34, + "name": "ThisModule", + "variant": "reference", + "kind": 4194304, + "flags": {}, + "sources": [ + { + "fileName": "mod.ts", + "line": 40, + "character": 12, + "url": "typedoc://mod.ts#L40" + } + ], + "target": 29 + }, { "id": 35, "name": "GH1453Helper", @@ -866,9 +866,9 @@ { "title": "References", "children": [ - 34, 31, - 32 + 32, + 34 ] }, { diff --git a/src/test/converter/exports/specs.nodoc.json b/src/test/converter/exports/specs.nodoc.json index efa9f878e..ed45fe79d 100644 --- a/src/test/converter/exports/specs.nodoc.json +++ b/src/test/converter/exports/specs.nodoc.json @@ -13,8 +13,8 @@ "flags": {}, "children": [ { - "id": 43, - "name": "Mod2", + "id": 45, + "name": "b", "variant": "reference", "kind": 4194304, "flags": {}, @@ -22,23 +22,23 @@ "summary": [ { "kind": "text", - "text": "This is a comment for Mod that overwrites the one specified in \"mod\"" + "text": "An export of a local under a different name." } ] }, "sources": [ { - "fileName": "export.ts", - "line": 14, - "character": 12, - "url": "typedoc://export.ts#L14" + "fileName": "mod.ts", + "line": 13, + "character": 14, + "url": "typedoc://mod.ts#L13" } ], - "target": 29 + "target": 31 }, { - "id": 45, - "name": "b", + "id": 43, + "name": "Mod2", "variant": "reference", "kind": 4194304, "flags": {}, @@ -46,27 +46,27 @@ "summary": [ { "kind": "text", - "text": "An export of a local under a different name." + "text": "This is a comment for Mod that overwrites the one specified in \"mod\"" } ] }, "sources": [ { - "fileName": "mod.ts", - "line": 13, - "character": 14, - "url": "typedoc://mod.ts#L13" + "fileName": "export.ts", + "line": 14, + "character": 12, + "url": "typedoc://export.ts#L14" } ], - "target": 31 + "target": 29 } ], "groups": [ { "title": "References", "children": [ - 43, - 45 + 45, + 43 ] } ], diff --git a/src/test/converter/function/specs.json b/src/test/converter/function/specs.json index c4c9a1ffd..62a576805 100644 --- a/src/test/converter/function/specs.json +++ b/src/test/converter/function/specs.json @@ -716,23 +716,23 @@ ] }, { - "id": 45, - "name": "assertIsNonNull", + "id": 39, + "name": "assertionFunction", "variant": "declaration", "kind": 64, "flags": {}, "sources": [ { "fileName": "function.ts", - "line": 145, + "line": 131, "character": 16, - "url": "typedoc://function.ts#L145" + "url": "typedoc://function.ts#L131" } ], "signatures": [ { - "id": 46, - "name": "assertIsNonNull", + "id": 40, + "name": "assertionFunction", "variant": "signature", "kind": 4096, "flags": {}, @@ -740,89 +740,65 @@ "summary": [ { "kind": "text", - "text": "Asserts that an argument is not null." + "text": "This is an assertion function." } ] }, "sources": [ { "fileName": "function.ts", - "line": 145, + "line": 131, "character": 16, - "url": "typedoc://function.ts#L145" - } - ], - "typeParameters": [ - { - "id": 47, - "name": "T", - "variant": "typeParam", - "kind": 131072, - "flags": {} + "url": "typedoc://function.ts#L131" } ], "parameters": [ { - "id": 48, - "name": "arg", + "id": 41, + "name": "condition", "variant": "param", "kind": 32768, "flags": {}, - "type": { - "type": "union", - "types": [ - { - "type": "intrinsic", - "name": "undefined" - }, - { - "type": "literal", - "value": null - }, + "comment": { + "summary": [ { - "type": "reference", - "target": 47, - "name": "T", - "package": "typedoc", - "refersToTypeParameter": true + "kind": "text", + "text": "The condition that is asserted to be true when this function returns." } ] + }, + "type": { + "type": "intrinsic", + "name": "boolean" } } ], "type": { "type": "predicate", - "name": "arg", - "asserts": true, - "targetType": { - "type": "reference", - "target": 47, - "name": "T", - "package": "typedoc", - "refersToTypeParameter": true - } + "name": "condition", + "asserts": true } } ] }, { - "id": 39, - "name": "assertionFunction", + "id": 45, + "name": "assertIsNonNull", "variant": "declaration", "kind": 64, "flags": {}, "sources": [ { "fileName": "function.ts", - "line": 131, + "line": 145, "character": 16, - "url": "typedoc://function.ts#L131" + "url": "typedoc://function.ts#L145" } ], "signatures": [ { - "id": 40, - "name": "assertionFunction", + "id": 46, + "name": "assertIsNonNull", "variant": "signature", "kind": 4096, "flags": {}, @@ -830,43 +806,67 @@ "summary": [ { "kind": "text", - "text": "This is an assertion function." + "text": "Asserts that an argument is not null." } ] }, "sources": [ { "fileName": "function.ts", - "line": 131, + "line": 145, "character": 16, - "url": "typedoc://function.ts#L131" + "url": "typedoc://function.ts#L145" + } + ], + "typeParameters": [ + { + "id": 47, + "name": "T", + "variant": "typeParam", + "kind": 131072, + "flags": {} } ], "parameters": [ { - "id": 41, - "name": "condition", + "id": 48, + "name": "arg", "variant": "param", "kind": 32768, "flags": {}, - "comment": { - "summary": [ + "type": { + "type": "union", + "types": [ { - "kind": "text", - "text": "The condition that is asserted to be true when this function returns." + "type": "intrinsic", + "name": "undefined" + }, + { + "type": "literal", + "value": null + }, + { + "type": "reference", + "target": 47, + "name": "T", + "package": "typedoc", + "refersToTypeParameter": true } ] - }, - "type": { - "type": "intrinsic", - "name": "boolean" } } ], "type": { "type": "predicate", - "name": "condition", - "asserts": true + "name": "arg", + "asserts": true, + "targetType": { + "type": "reference", + "target": 47, + "name": "T", + "package": "typedoc", + "refersToTypeParameter": true + } } } ] @@ -2028,8 +2028,8 @@ "title": "Functions", "children": [ 76, - 45, 39, + 45, 53, 42, 2, diff --git a/src/test/issues.c2.test.ts b/src/test/issues.c2.test.ts index 9fec15046..303cb35c2 100644 --- a/src/test/issues.c2.test.ts +++ b/src/test/issues.c2.test.ts @@ -1416,7 +1416,7 @@ describe("Issue Tests", () => { const project = convert(); const theme = new DefaultTheme(app.renderer); - const page = new PageEvent("hierarchy", project); + const page = new PageEvent(project); page.project = project; const context = theme.getRenderContext(page); context.hierarchyTemplate(page);