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.yml does not specify version #883

Merged
merged 7 commits into from
Jun 19, 2024

Conversation

alaindresse
Copy link
Contributor

@alaindresse alaindresse commented May 27, 2024

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 alaindresse changed the title fix asciidoc preview wen antora.yml does not specify version fix asciidoc preview when antora.yml does not specify version May 28, 2024
@alaindresse
Copy link
Contributor Author

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
Copy link
Member

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
Copy link
Contributor Author

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

Yes, that is exactly the case:

  • If I add the version in the playbook, then it is no longer mandatory in the antora.yml, and should actually be absent for the version in the playbook to work.
  • If I accordingly remove the version from the antora.yml, before my changes, I have to preview in vscode, even though the antora generation works nicely with no errors or warnings.

package.json Outdated Show resolved Hide resolved
@ggrossetie
Copy link
Member

@alaindresse Left a few comments otherwise 👍🏻

@ggrossetie
Copy link
Member

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

assert.strictEqual(images[0].src.version, null)

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
Copy link
Contributor Author

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

@alaindresse
Copy link
Contributor Author

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
Copy link
Member

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

@ggrossetie
Copy link
Member

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 ggrossetie force-pushed the allow-missing-version branch from 847d64f to c25bad3 Compare June 19, 2024 10:10
@ggrossetie
Copy link
Member

All good 🎉
Thanks!

@ggrossetie ggrossetie merged commit 43c0940 into asciidoctor:master Jun 19, 2024
2 checks passed
@alaindresse alaindresse deleted the allow-missing-version branch June 21, 2024 09:20
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.

Antora preview doesn't work if version is not specified in antora.yml
2 participants