Skip to content
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

fix asciidoc preview when antora is using version: true #871

Conversation

leonardopavanrocha
Copy link
Contributor

Resolves #829

Currently if our antora.yml is using version: true, it is not possible to render a preview of the asciidoc file as version is expected to be a string and it fails with the following trace:

 Unable to get Antora context for .../antora/modules/ROOT/pages/index.adoc TypeError: The "path" argument must be of type string. Received type boolean (true)
    at NodeError (node:internal/errors:405:5)
    at validateString (node:internal/validators:162:11)
    at Object.join (node:path:1165:7)
    at computeOut (/Users/leonardo.pavan.rocha/tools/asciidoctor-vscode/node_modules/@antora/content-classifier/lib/content-catalog.js:500:27)
    at ContentCatalog.addFile (/Users/leonardo.pavan.rocha/tools/asciidoctor-vscode/node_modules/@antora/content-classifier/lib/content-catalog.js:185:18)
    at /Users/leonardo.pavan.rocha/tools/asciidoctor-vscode/node_modules/@antora/content-classifier/lib/classify-content.js:38:87
    at Array.forEach (<anonymous>)
    at /Users/leonardo.pavan.rocha/tools/asciidoctor-vscode/node_modules/@antora/content-classifier/lib/classify-content.js:38:13
    at Map.forEach (<anonymous>)
    at classifyContent (/Users/leonardo.pavan.rocha/tools/asciidoctor-vscode/node_modules/@antora/content-classifier/lib/classify-content.js:34:6)
    at /Users/leonardo.pavan.rocha/tools/asciidoctor-vscode/src/features/antora/antoraSupport.ts:310:34
    at Generator.next (<anonymous>)
    at fulfilled (/Users/leonardo.pavan.rocha/tools/asciidoctor-vscode/dist/src/features/antora/antoraSupport.js:28:58) (at console.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:142:60451))

When antora is using version: true, it means that it will use the refname (branch/tags). Ideally the fix would use the refname, but I am not sure if we can access that from within the extension. I would appreciate any input on that. My approach was to simply replace it for an empty string for now.

@leonardopavanrocha leonardopavanrocha force-pushed the fix-antora-version-true-not-rendering-preview branch from 6f73077 to aa2d1cb Compare April 23, 2024 15:02
@leonardopavanrocha leonardopavanrocha force-pushed the fix-antora-version-true-not-rendering-preview branch from aa2d1cb to e164c6b Compare April 23, 2024 15:07
@ggrossetie
Copy link
Member

My approach was to simply replace it for an empty string for now.

@mojavelinux do you think it will cause any issue?

@mojavelinux
Copy link
Member

For the purpose of the preview, I don't think it would be an issue. For the purpose of rendering a single component version, the value doesn't actually matter. It's when there are inbound references to resources in that component version from another that it becomes an issue.

As I often say, how does the IntelliJ plugin handle this situation?

@ggrossetie
Copy link
Member

The Intellij plugin does not use Antora (i.e., it does not use the ContentCatalog.addFile method) so it does not have this "issue". I guess one use case where it won't work is when the user is using an xref that includes a specific version?

@ggrossetie ggrossetie merged commit 6892d3c into asciidoctor:master Apr 29, 2024
2 checks passed
@leonardopavanrocha
Copy link
Contributor Author

Hey guys! Thank you for merging this and thanks for the guidance on this topic @ggrossetie @mojavelinux. Let me know if I can help with anything else 🙂

@mojavelinux
Copy link
Member

The Intellij plugin does not use Antora (i.e., it does not use the ContentCatalog.addFile method) so it does not have this "issue".

It may not use Antora directly, but surely it handles the situation when the version is set to true and references are used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

image preview does not work when version: true configured in antora.yml
3 participants