krisztianb / typedoc-plugin-replace-text Goto Github PK
View Code? Open in Web Editor NEWPlugin for TypeDoc that replaces text in the documentation
License: ISC License
Plugin for TypeDoc that replaces text in the documentation
License: ISC License
I have a folder of examples in my project and I would like to use this plugin to replace references to these example files with the actual code, fx:
::--example: someExample.ts, 15, 32--::
Would become a code block containing lines 15-32 of the someExample.ts
file.
The thing that is preventing me from accomplishing it with the current version of this plugin, is that it doesn't seem to support replacing snippets with the contents of other files.
Would you consider supporting this usecase with this plugin? Do you know other non-hacky ways of doing this?
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.
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"
]
}
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.
typedoc-plugin-replace-text/package.json
Line 27 in 053205f
Currently plugin seems to be replacing text only in project's README.md, but not ones which are included with include.
I was hoping to use this package to replace the content of a comment with the contents of a file just like #4. I can get something to work using the replacer function, but in order to get the path to the file I want to read I would need the path to the current file being observed. For example, if I have a comment defined in a file located in src/my/location/Test.ts
and a corresponding src/my/location/README.md
I would like to do something like this:
/**
* My test class.
*
* [[include ./README.md]]
*/
class Test {}
In order to resolve the location of ./README.md
, I would need to know I'm located in src/my/location/Test.ts
. It looks like the replacer function just gives info about the string match. Would it be feasible to add some more info about the match's file path to the replacer function?
Using a plugin config like this doesn't produce the expected results:
"replaceText": {
"inCodeCommentText": false,
"inCodeCommentTags": false,
"inIncludedFiles": true,
"replacements": [
{
"pattern": "A",
"replace": "B"
}
]
}
Expected
Once would expect that A
is replaced by B
only in the README
and other included markdown files as suggested by the plugin's README.
Actual
With the config above A
is replaced everywhere by B
even in code comment text and code comment tags.
typedoc-plugin-replace-text/package.json
Line 29 in aafca69
Maybe: "typedoc": "0.24.x | 0.25.x"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.