-
Notifications
You must be signed in to change notification settings - Fork 18
feat(apib): add format link #534
base: master
Are you sure you want to change the base?
Conversation
packages/apib-parser/lib/adapter.js
Outdated
refractElement.element = result.element; | ||
refractElement.meta = formatLink; | ||
refractElement.content = result.content; | ||
return refractElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One caveat here is that if the underlying parser added any other meta or attributes they would go missing. It might be a bit simpler to construct a minim elements from the given result. In options
there is namespace
which can be used as a minim namespace. You can get hold of a ParseResult element instance in the same way that the other parsers work. Returning a ParseResult here does not change the behaviour, the API Elements Core logic detects if the returned value is a Minim element, in the cases it is not, it will convert it to be one (thus doing what you'd be doing here).
const { namespace } = options;
const parseResult = namespace.fromRefract(source);
.. new namespace.elements.Link(...);
return parseResult;
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kylef in options
there is not namespace
, I don't know how to access it here. Seems to me that API Elements are managed internally by the drafter
function, so by Protagonist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The options passed into the function:
function parse({
source, generateSourceMap, generateMessageBody, generateMessageBodySchema,
requireBlueprintName,
}) {
can be adjusted to add namespace
. It doesn't need to be added to the options passed to drafter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
packages/apib-parser/lib/adapter.js
Outdated
if (!isAnnotation(parseResult.content[0])) { | ||
const link = new Link(); | ||
|
||
link.title = 'Apiary Blueprint'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
link.title = 'Apiary Blueprint'; | |
link.title = 'API Blueprint'; |
This is the API Blueprint adapter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
packages/apib-parser/lib/adapter.js
Outdated
const isAnnotation = element => element.element === 'annotation'; | ||
const { Link } = namespace.elements; | ||
|
||
if (!isAnnotation(parseResult.content[0])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain the intent of this check? I am not sure it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of error it does not add the format link, do you want to remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed condition e310ea3
Closes APIARY-6103