-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Replace with contents from a file #4
Comments
Hi. Yes, you are right that the plugin currently doesn't support this. It only supports replacing text (matched by a Regex) with another text. As far as I know you can include markdown files in comments like this: /**
* My test class.
*
* [[include ./test.md]]
*/
class Test {} Does that help you? To be honest this seems like a rather big change to the plugin. Maybe one should write a new one specifically for this task. |
All right, thanks for the response. I'll either fork/create a new plugin or just link to the examples using hyperlinks instead. |
Another solution came to my mind: One could define a function instead of the text that should be used as the replacement. Then the function could do the work (reading things from a file etc.). But I'm not sure if TypeDoc can be configured using a .js instead of a .json file. I will have to investigate this further. |
That would be a lot more powerful and still pretty clean. Maybe you could define it in a .json and provide a path to a "replaceText": {
...
"includeFunctions": "/some/path/to/functions.ts",
"replacements": [
{
"pattern": "somePattern",
"replace": "functionDefinedInIncludedFile"
},
]
} I still do think configuring in js is the better solution, but if its not possible |
TypeDoc does allow JavaScript configuration files so this should be doable. I will fiddle around with it and let you know. |
I got this working and you can install it as 2.3.0-beta from NPM. The replacer function is simply forwarded as an argument to the There is also a very basic example in the updated README of the beta package. See how it works for you and please give me feedback. |
Hello, I installed it and played around with it. It was actually able to do the things I wanted (inlining code examples and linking to specific git commits) and it worked pretty well. I did however later find a repo that provided me with what I needed in a neater way. I will post my config in a codesnippet in this issue as an example of how the replacer function can be used, either today or tomorrow. After that I will go ahead and close the issue. Thank you. |
Thanks for reporting back. Glad to hear that you found a solution. |
Released in 3.0.0 |
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?
The text was updated successfully, but these errors were encountered: