-
Notifications
You must be signed in to change notification settings - Fork 712
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
support regions in @includeCode #2816
base: master
Are you sure you want to change the base?
Conversation
Yes, this seems reasonable. Might want to split the logic out into its own function at this point.
Is there any case in which this would be a better option than using a region? It seems like an objectively worse UX to me... |
I'll probably be extracting a function to its own file for this, indeed.
Agreed. I'm just thinking of the case where you want to include code from a file you don't control or in which you can't add comments to define regions (think JSON, for example, which does't support comments). In this case the line-numbers seem like the only text-based approach (as opposed to using a language-aware AST) that could work… Can I let you decide if it's worth including? |
Ah, that's a very fair point, line numbers is probably worth it at some point |
The holidays are over so I'm back at it Today, but I think I already made a mistake. I tried pulling the latest changes before pushing mine but this PR is still showing more than my own changes… I'm not sure how to make the PR clean from here… Help? Other questions and comments about my actual code changes:
Thanks for any and all feedback. Looking forward to wrapping this up and marking it ready for official review and eventual merging :) |
Not exactly sure how this happened... it looks like some kind of rebase gone wrong as Git thinks you went and modified every commit. If you run
This is fine, I usually toss new ones into https://devina.io/redos-checker to check
This looks pretty reasonable to me, I'm considering going the same route as TypeScript for these names someday which will make them automatically generated, but for now it makes sense. The names are completely subject to change anyways.
It looks like I didn't write unit tests specifically for this as they were used in TypeDoc's site so effectively tested there. There's a test that was added later (search for 2800 in issues.c2.test.ts)
Don't worry about adding translations, they'll just use English until someone who speaks other languages natively adds a translation.
I probably would have left the region tag regexes in the IncludePlugin file, fine where they are though. I tend to only split things out to other files if they are useful in more than one place.
Looks fine to me! I'll take a closer look at the code tomorrow, off to spend more time with family :) |
WORK IN PROGRESS / DO NOT MERGE
This is a proof of concept for supporting regions in
@includeCode
tags, meaning you could insert part of a file as a code block by referencing a region of that file.Example
sourceFile.ts
documents/some-page.md
Here is an example: {@includeCode src/sourceFile.ts#regionName} This is useful for reasons.
output:
Here is an example:
This is useful for reasons.
Notes
@includeCode
tag reference #2814@Gerrit0 if this basic strategy seems OK, I would add the following to this PR before merging:
TO DO
//#region NAME
instead of// #region NAME
)@include
tag as wellsite/tags/include.md
/example
)Thoughts? Questions? Advice?
Updates