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.
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.
@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.
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.
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.
| link.title = 'Apiary Blueprint'; | |
| link.title = 'API Blueprint'; |
This is the API Blueprint adapter
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.
Can you please explain the intent of this check? I am not sure it is needed.
There was a problem hiding this comment.
In case of error it does not add the format link, do you want to remove it?
There was a problem hiding this comment.

Closes APIARY-6103