Support other plugins using the @apiExample element #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Stricter pattern matching
Previously this plugin would catch all elements with the pattern:
This PR makes sure that
apidoc-plugin-example
only runs if the element matches any of these 3 patternsFull regex here
/^\s*\{(json|jsonschema|xml)\s*=(.+?)\}\s*(?:\s+(.+?))?\s(.+?)$/g;
Bugfix
PR fixes a bug mentioned in #4, which happened because the plugin did not check if regex-match returned
null
before running.pop()
and.push()
. As an example, this would crash theapidoc
command ifapiExample {curl}
was used together with plugin.Further with the stricter pattern-matching mentioned above, we can remove an
if
-statement because we can trust parsed values more.Also we now make sure to run
.pop()
and.push()
right next to each other, as the program will be in an inconsistent state if only one of them runs.