krisztianb / typedoc-plugin-replace-text

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

Replacements aren't working with Title and Signature #8

Closed Kartanovicius closed 8 months ago

Kartanovicius commented 10 months ago

Impossible to replace the string CRM_ACCOUNT_CONTEXT_SET to any other value.

image

krisztianb commented 10 months ago

Hi. :wave:

Currently the plugin supports replacing text in:

It doesn't support replacing things that are directly taken from the source code.

May I ask what your use case is? Why are you not naming the variable the way to want it to be named in the documentation?

Kartanovicius commented 10 months ago

Hi,

We are using the same file in multiple places in our application, and we have been naming them this way because they are constants. Of course, we can rename them in the application or create some mapping from one name to another, but the easiest and most logical approach would be to only rename them in the documentation.

Kind regards,

krisztianb commented 10 months ago

Unfortunately I don't understand what you are doing. 😄 Why do you want the constants to be named differently than their real name? Doesn't that undermine the purpose of the documentation to reflect the code?

machaj commented 10 months ago

Hello, I think that our use case is not very common probably. In the example which @Kartanovicius mentioned, we have defined a constant with a value. The value is a name of function which can be used in code snippet. Usually something like:

export const crmAccountContextSet = async ({ payload, api: { notify }}) => {
  await notify.success('Triggered crmAccountContextSet');
  // another code
}

These snippets are written by other developers and they are not a part of our codebase. They use a documentation which is generated from our code, but for them is more relevant the value of the constant then the name.

For us is more relevant the name of the constant, but the generated documentation itself not.

So there are two groups of people with different needs, that is the reason why we are looking for something which will modify the generated documentation.

I hope that the use case makes more sense now :-)

krisztianb commented 10 months ago

That makes it clearer somewhat but I still don't see why this makes sense. In the documentation you have both the name of the constant and its value. If you rename the constant than all references to it must be renamed also or not? Then the documentation doesn't reflect the code which kind of goes against the point of having a documentation.

Kartanovicius commented 10 months ago

This documentation is not intended for developers but for those who need to configure our product using JavaScript code. For them we have changed constant name to function like to avoid confusion from their side.

If we decide to rename a constant, we aim to update it across all documentation pages.

Initially we were looking for @alias but it's not existing in TypeDoc and this plugin could do almost the same alias in JSDoc. :3

krisztianb commented 10 months ago

But you still want to replace the name everywhere in the documentation, right? So basically you want to rename the variable reflection.

Kartanovicius commented 10 months ago

Yes, exactly.

krisztianb commented 10 months ago

I've given this some thought and have to tell you that I don't see this fit into the intention of this plugin. The requested functionality (renaming reflections) should imho be implemented in a separate plugin. It will most certainly also need additional options/settings (eg. specifying where you want things to get renamed and where not).