Skip to content

Commit

Permalink
Sort using localeCompare
Browse files Browse the repository at this point in the history
Resolves #2684
  • Loading branch information
Gerrit0 committed Aug 23, 2024
1 parent bd5cd66 commit 3dc7e96
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 175 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 11 additions & 5 deletions src/lib/output/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class RendererEvent {
public createPageEvent<Model>(
mapping: UrlMapping<Model>,
): [RenderTemplate<PageEvent<Model>>, PageEvent<Model>] {
const event = new PageEvent<Model>(PageEvent.BEGIN, mapping.model);
const event = new PageEvent<Model>(mapping.model);
event.project = this.project;
event.url = mapping.url;
event.filename = Path.join(this.outputDirectory, mapping.url);
Expand All @@ -84,7 +84,7 @@ export interface PageHeading {
* @see {@link Renderer.EVENT_BEGIN_PAGE}
* @see {@link Renderer.EVENT_END_PAGE}
*/
export class PageEvent<out Model = unknown> extends Event {
export class PageEvent<out Model = unknown> {
/**
* The project the renderer is currently processing.
*/
Expand Down Expand Up @@ -152,9 +152,15 @@ export class PageEvent<out Model = unknown> 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;

Check failure on line 162 in src/lib/output/events.ts

View workflow job for this annotation

GitHub Actions / Node 22 Release

This assertion is unnecessary since it does not change the type of the expression

Check failure on line 162 in src/lib/output/events.ts

View workflow job for this annotation

GitHub Actions / Node 18

This assertion is unnecessary since it does not change the type of the expression

Check failure on line 162 in src/lib/output/events.ts

View workflow job for this annotation

GitHub Actions / Node 20

This assertion is unnecessary since it does not change the type of the expression

Check failure on line 162 in src/lib/output/events.ts

View workflow job for this annotation

GitHub Actions / Node 18 Windows

This assertion is unnecessary since it does not change the type of the expression
}
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/lib/output/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,11 @@ export interface RendererEvents {
*
* * {@link Renderer.EVENT_BEGIN_PAGE}<br>
* 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}<br>
* 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}<br>
* Triggered after the renderer has written all documents. The listener receives
Expand Down
4 changes: 2 additions & 2 deletions src/lib/utils/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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 (
Expand Down
156 changes: 78 additions & 78 deletions src/test/converter/exports/specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -419,14 +419,14 @@
{
"title": "References",
"children": [
44,
45,
40,
48,
41,
43,
42,
47,
44,
45,
40
47
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -866,9 +866,9 @@
{
"title": "References",
"children": [
34,
31,
32
32,
34
]
},
{
Expand Down
36 changes: 18 additions & 18 deletions src/test/converter/exports/specs.nodoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,60 @@
"flags": {},
"children": [
{
"id": 43,
"name": "Mod2",
"id": 45,
"name": "b",
"variant": "reference",
"kind": 4194304,
"flags": {},
"comment": {
"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": {},
"comment": {
"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
]
}
],
Expand Down
Loading

0 comments on commit 3dc7e96

Please sign in to comment.