krisztianb / typedoc-plugin-replace-text

Plugin for TypeDoc that replaces text in the documentation
ISC License
5 stars 2 forks source link

Plugin doesn't work #3

Closed Voo2 closed 1 year ago

Voo2 commented 1 year ago

Question

I have a very special project structure (It's not possible to change this structure) and there I have problems to get typodoc plugins installed.

Info

Directory structure

myProject
--apps
----myProject
------tsconfig.json
--libs
----ui
------common
--------typedoc.json
--------tsconfig.json
------desktop
--------typedoc.json
--------tsconfig.json
----platform
------common
--------typedoc.json
--------tsconfig.json
------access
--------typedoc.json
--------tsconfig.json
--typedoc.json
--typedoc.base.json

Content of myProject\typedoc.base.json

{
    "$schema": "https://typedoc.org/schema.json",
    "includeVersion": true
}

Content of myProject\typedoc.json

{
    "basePath": "./",
    "entryPoints": [
        "libs/platform/*",
        "libs/ui/*"
    ],
    "name": "Documentation",
    "entryPointStrategy": "packages",
    "out": "./dist/typedoc",
    "plugin": [
        "typedoc-umlclass",
        "typedoc-plugin-coverage",
        "typedoc-plugin-replace-text"
    ],
    "umlClassDiagram": {
        "type": "detailed",
        "location": "local",
        "format": "svg",
        "umlClassDiagramVerboseOutput": true
    },
    "replaceText": {
        "inCodeCommentText": true,
        "inCodeCommentTags": true,
        "inIncludedFiles": true,
        "replacements": [
            {
                "pattern": "King Kong",
                "flags": "gi",
                "replace": "[King Kong](https://github.com/king-kong)"
            }
        ]
    }
}

Content of myProject\libs\platform\common\typedoc.json (every typedoc.json in a nx-module looks the same)

{
    "extends": [
        "../../../typedoc.base.json"
    ],
    "entryPoints": [
        "src/index.ts"
    ]
}

Problem Description

When I run the command npx typedoc, the documentation is generated successfully. However, the string "King Kong" (I inserted it on various places, e.g. param description, class description etc) wasn't replaced.

But the plugin is loaded, which is also displayed during execution. The config entries also seem to be pulled, because if I make a spelling mistake on purpose, this would lead directly to the termination of the generation.

[info] Loaded plugin typedoc-plugin-replace-text

Does anyone knows what the problem here is?

This was the only way I got typedoc working. If there is a better way, I am open to using it. I tried to do everything from the instructions, but everything else didn't work. If any info is needed, I'll be happy to provide it.

krisztianb commented 1 year ago

Hi. I suspect that the plugins is loaded but it for some reason can't read the configuration that you provided so it doesn't replace anything.

This could be related to entryPointStrategy being set to packages which I already noticed with some of my other plugins. I will check this out and let you know.

krisztianb commented 1 year ago

Is your project by any chance accessible via Github so that I can fiddle around with the plugin there?

Voo2 commented 1 year ago

Unfortunately not. But in the meantime I have the same suspicions as you. I have installed other plug-ins in our project and noticed that some of them work, e.g. typedoc-plugin-coverage or typedoc-plugin-extras. Theirs config is loaded from my tsconfig.json. Of the plug-ins that don't work, typedoc-plugin-custom-tags-v2 is particularly interesting. There I found that the app.options object is undefined. Although I have integrated the settings correctly in jsconfig.json, it cannot read them. I directly set the settings I wanted in the plugin code and now the plugin works as expected.

Of course, this is not a solution, especially not for the other non-working plugins, e.g. typedoc-plugin-replace-text, and typedoc-umlclass.

Voo2 commented 1 year ago

I have solved the problem and it was so clear in retrospect. Each NX module is considered separately and its tsconfig.json is used. I had only written the settings in the root tsconfig.json, which was wrong. I have to make the settings in tsconfig.base.json, then everything works.

Thanks for your commitment.