asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
340 stars 97 forks source link

fix asciidoc preview when antora.yml does not specify version #883

Closed alaindresse closed 5 months ago

alaindresse commented 6 months ago

Resolves #882

Currently, if our antora.yml does not specify a version (required to add a fallback for the version in the antora playbook), it is impossible to preview an asciidoc file.

This pull request extends the approach from @leonardopavanrocha in #871, namely setting the version to an empty string when it is not specified in antora.yml.

Note:: I also had to bumb the vscode engine number to test this.

alaindresse commented 6 months ago

Changed my code to set version to a short hash of the path of the antora.yml. I was getting issues with duplicate versions for components for which the source was distributed across several folders in the repo.

Use case for the duplication: monorepo with documentation of individual components that I want to consolidate into a single component with appropriate navigation.

ggrossetie commented 5 months ago

According to the documentation the version is "mandatory" unless inherited from the content source in the playbook. Is that your case?

https://docs.antora.org/antora/latest/component-name-and-version/#antora-yml-requirements

alaindresse commented 5 months ago

@ggrossetie thanks for taking the time to look into this despite your busy schedule!

Yes, that is exactly the case:

ggrossetie commented 5 months ago

@alaindresse Left a few comments otherwise 👍🏻

ggrossetie commented 5 months ago

One test is failing because we assert that the version is null but the value is now a random value:

https://github.com/asciidoctor/asciidoctor-vscode/blob/714a0907dc728db15860709814e65152d8a50528/src/test/antoraSupport.test.ts#L188

I don't think we should generate a random value when the version is explicitly null with the ~ symbol.

The ~ values defines a component version as unversioned

https://docs.antora.org/antora/latest/component-version-key/#key

alaindresse commented 5 months ago

@ggrossetie thanks for your comments. I believe they are now addressed.

alaindresse commented 5 months ago

I ran the tests, using npm run test and saw a message saying that all tests passed, but I also saw:

Failed to load message bundle for file /Users/alaindresse/code/asciidoctor-vscode/dist/src/features/antora/antoraSupport
Failed to load message bundle for file /Users/alaindresse/code/asciidoctor-vscode/dist/src/asciidoctorWebViewConverter
Failed to load message bundle for file /Users/alaindresse/code/asciidoctor-vscode/dist/src/security
Failed to load message bundle for file /Users/alaindresse/code/asciidoctor-vscode/dist/src/features/documentLinkProvider

And did not see any report on the antoraSupport tests.

What is the proper way to run the tests ?

ggrossetie commented 5 months ago

@alaindresse Thanks, could you please run npm i locally and commit the package-lock.json. Apart from that 👍🏻

ggrossetie commented 5 months ago

I ran the tests, using npm run test and saw a message saying that all tests passed, but I also saw:

Message bundle does not properly load during tests (or at least I don't know how to make them work in tests) but it does not prevent tests from running. So this messages can be safely ignored 😅

ggrossetie commented 5 months ago

All good 🎉 Thanks!