Skip to content

Commit

Permalink
Merge branch 'typedoc-0.23'
Browse files Browse the repository at this point in the history
  • Loading branch information
krisztianb committed Jul 3, 2022
2 parents e1b6862 + d78dd65 commit d28559a
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 120 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.0.0] - 2022-07-03
### Breaking Changes
- Support changed to TypeDoc versions 0.23.x due to a breaking change in TypeDoc's API.
### Added
- Option `mergeModulesMergeMode` now has a new value `module-category` to merge modules with the same name but only
if they are within the same category.
### Fixed
- Renaming of default exports now also works for: enums, object literals, type literals and type aliases.

## [3.1.0] - 2021-12-08
### Added
- When merging modules by name you can use the comment tag `@mergeTarget` to define the module into which the other
Expand Down Expand Up @@ -42,7 +51,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

First release

[unreleased]: https://github.com/krisztianb/typedoc-plugin-merge-modules/compare/v3.1.0...HEAD
[unreleased]: https://github.com/krisztianb/typedoc-plugin-merge-modules/compare/v4.0.0...HEAD
[4.0.0]: https://github.com/krisztianb/typedoc-plugin-merge-modules/releases/tag/v4.0.0
[3.1.0]: https://github.com/krisztianb/typedoc-plugin-merge-modules/releases/tag/v3.1.0
[3.0.2]: https://github.com/krisztianb/typedoc-plugin-merge-modules/releases/tag/v3.0.2
[3.0.1]: https://github.com/krisztianb/typedoc-plugin-merge-modules/releases/tag/v3.0.1
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ The following options are added to TypeDoc when the plugin is installed:
| Name & Format | Description | Default |
| ------------- | ----------- | ------- |
| **mergeModulesRenameDefaults** `<boolean>` | Defines if the plugin should rename default exports to their original name. | `true` |
| **mergeModulesMergeMode** `<"project"\|"module"\|"off">` | Defines if the plugin should merge all modules into the project or if it should merge modules based on their name or module annotation. You can use the value `"off"` to disable the plugin. | `"project"` |
| **mergeModulesMergeMode** `<"project"\|"module"\|"module-category"\|"off">` | Defines how the plugin should merge modules:<br/><br/><ul><li>`"project"` = The plugin merges the content of all modules into the project root.</li><li>`"module"` = The plugin merges modules with the same name. By default the filename is the module name, which you can overwrite using [module comments](https://typedoc.org/tags/module/).</li><li>`"module-category"` = Same as `"module"` but will only merge modules that have the same [category](https://typedoc.org/tags/category/).</li><li>`"off"` = Disables the plugin.</li></ul> | `"project"` |

When using `mergeModulesMergeMode: module` in combination with [module comments](https://typedoc.org/guides/doccomments/#files) you should add the tag `@mergeTarget` to the comment of the module whose comment should be used in the merge result.
When you set `mergeModulesMergeMode` to `"module"` OR `"module-category"` in combination with [module comments](https://typedoc.org/tags/module/) you should add the tag `@mergeTarget` to the comment of the module whose comment should be used in the merge result.

## Bugs

Expand Down
141 changes: 72 additions & 69 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typedoc-plugin-merge-modules",
"version": "3.1.0",
"version": "4.0.0",
"description": "Plugin for TypeDoc that merges the content of modules.",
"author": {
"name": "Krisztián Balla",
Expand All @@ -12,19 +12,19 @@
],
"devDependencies": {
"@types/node": "14.18.0",
"@typescript-eslint/eslint-plugin": "5.30.1",
"@typescript-eslint/parser": "5.30.1",
"eslint": "8.18.0",
"@typescript-eslint/eslint-plugin": "5.30.3",
"@typescript-eslint/parser": "5.30.3",
"eslint": "8.19.0",
"eslint-plugin-jsdoc": "39.3.3",
"eslint-plugin-ordered-imports": "0.6.0",
"eslint-plugin-unicorn": "43.0.0",
"prettier": "2.7.1",
"rimraf": "3.0.2",
"typedoc": "0.22.10",
"typedoc": "0.23.5",
"typescript": "4.7.4"
},
"peerDependencies": {
"typedoc": "0.21.x || 0.22.x"
"typedoc": "0.23.x"
},
"repository": {
"type": "git",
Expand Down
17 changes: 5 additions & 12 deletions src/merger/module_bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import { removeTagFromCommentsOf } from "./utils";
* Name of the comment tag that can be used to mark a module as the target module within the bundle.
* The target module is the one into which all the modules of the bundle are merged.
*/
const targetModuleCommentTagName = "mergeTarget";
const targetModuleCommentTag = "@mergeTarget";

/**
* Class representing a group of modules.
*/
export class ModuleBundle {
/** The name of the module bundle. */
private readonly name: string;

/** The project in which all modules are in. */
private readonly project: ProjectReflection;

Expand All @@ -22,11 +19,9 @@ export class ModuleBundle {

/**
* Creates a new module bundle instance.
* @param name The name of the module bundle.
* @param project The project in which all modules are in.
*/
public constructor(name: string, project: ProjectReflection) {
this.name = name;
public constructor(project: ProjectReflection) {
this.project = project;
}

Expand All @@ -49,7 +44,7 @@ export class ModuleBundle {

// get target module
const targetModule = this.getTargetModule();
removeTagFromCommentsOf(targetModule, targetModuleCommentTagName);
removeTagFromCommentsOf(targetModule, targetModuleCommentTag);

// set target module for all children
childrenOfAllModules.forEach((child) => (child.parent = targetModule));
Expand All @@ -72,17 +67,15 @@ export class ModuleBundle {
// 1. search for the first module which is marked with a specific tag
const firstModuleWithTargetTag = this.modules.find(
(module) =>
module.comment?.tags.findIndex(
(tag) => tag.tagName.toLowerCase() === targetModuleCommentTagName.toLowerCase(),
) !== -1,
module.comment && module.comment.blockTags.findIndex((ct) => ct.tag === targetModuleCommentTag) !== -1,
);

if (firstModuleWithTargetTag) {
return firstModuleWithTargetTag;
}

// 2. search for the first module with a comment
const firstModuleWithComment = this.modules.find((module) => module.comment?.shortText);
const firstModuleWithComment = this.modules.find((module) => (module.comment?.summary.length ?? 0) > 0);

if (firstModuleWithComment) {
return firstModuleWithComment;
Expand Down
Loading

0 comments on commit d28559a

Please sign in to comment.