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

Overwrite inventory version in deploydocs #2449

Merged

Conversation

goerz
Copy link
Member

@goerz goerz commented Feb 12, 2024

This unconditionally overwrites an existing inventory version with the version determined by deploydocs. This only happens when deploydocs actually knows the version. For dev-deployments, an existing version is left unchanged.

Under normal circumstances, the existing version will already be the correct one, so this should do nothing. If the deploydocs actually has to change the version, that would indicate that something is set up incorrectly, and thus a warning will be printed (but no error)

This PR is just #2442 with the tweak discussed in #2442 (comment). This makes #2442 less breaking: repos that are set up to contain only the documentation for some other package but don't declare the version of that package in some Project.toml/VERSION file won't get an error, but instead just a @warn. Their deployment will continue to work without them having to make any changes to their setup.

It satisfies @mortenpi's desire that deploydocs should have the last word and unconditionally patch in the version if it can determine a version from the git tags / the deployment folder name. Ultimately, this PR has the same final outcome as #2448, but the "fallback" is already in makedocs so that the inventory has the correct version already after makedocs. That also means there is no need for a manual inventory_version option to HTML.

I'd be quite happy with this compromise.

@goerz
Copy link
Member Author

goerz commented Feb 22, 2024

Per the discussion on Slack, I've revised this so that it takes a version only from a Project.toml that is in the parent folder of the documentation root (docs). This is to ensure that the autodetection is restricted to projects with a standard setup. For non-standard setups, e.g., documentation-only repositories or monorepos, makedocs may emit a warning asking that an inventory_version should be set manually, but it will leave the version blank.

A manual inventory version can still be set by passing an explicit inventory_version to the HTML() options of makedocs. Moreover, an explicit inventory_version="" opts out of setting a version in makedocs altogether (and suppresses any warnings that would be generated otherwise).

In all cases, deploydocs will unconditionally overwrite the inventory version when deploying a tagged release. If the version in deploydocs contradicts a manually set / autodetected version, it will emit a warning, but still win out.

This is required to set the inventory version for the Julia project
itself.

Also adds (implicit) support for `JuliaProject.toml`. This is not
documented, as it's understood that `JuliaProject.toml` is just an alias
for `Project.toml`, and not something we want to confuse people with too
much.
If `deploydocs` is deploying for a tagged version, verify that that
version matches the `version` in the `objects.inv` inventory file. If
not, throw an error: The inventory `version` must never contradict what
the version-selection-menu shows.
This unconditionally overwrites an existing inventory `version` with the
version determined by `deploydocs`. This only happens when `deploydocs`
actually knows the version. For `dev`-deployments, an existing `version`
is left unchanged.

Under normal circumstances, the existing `version` will already be the
correct one, so this should do nothing. If the `deploydocs` actually has
to *change* the version, that would indicate that something is set up
incorrectly, and thus a warning will be printed.
In order to prevent an auto-detected inventory version being incorrect
for unusual setups (e.g., monorepo), we only consider a
`docs/../Project.toml` file when looking up a version. Everything else
will leave the version blank in `makedocs`, respectively require
explicitly setting `inventory_version` manually
@goerz goerz force-pushed the mg/inventory-version-overwrite-in-deploydocs branch from a6cdd06 to cdac0d3 Compare February 22, 2024 17:15
@goerz goerz merged commit 8e2e5e8 into mg/write-inventory Feb 22, 2024
17 of 23 checks passed
@goerz goerz deleted the mg/inventory-version-overwrite-in-deploydocs branch February 22, 2024 17:20
mortenpi pushed a commit that referenced this pull request Feb 27, 2024
* Write inventory files

* Add test of inventories

* Add documentation

* Write only `objects.inv`

Removes the code for writing `inventory.toml.gz`.

* Fix inventory for md filenames with spaces

* Set inventory version (#2449)

* Obtain inventory version from Project.toml

* Overwrite inventory version in `deploydocs`

This unconditionally overwrites an existing inventory `version` with the
version determined by `deploydocs`. This only happens when `deploydocs`
actually knows the version. For `dev`-deployments, an existing `version`
is left unchanged.

Under normal circumstances, the existing `version` will already be the
correct one, so this should do nothing. If the `deploydocs` actually has
to *change* the version, that would indicate that something is set up
incorrectly, and thus a warning will be printed.

* Restrict inventory version from `Project.toml` to standard setups

In order to prevent an auto-detected inventory version being incorrect
for unusual setups (e.g., monorepo), we only consider a
`docs/../Project.toml` file when looking up a version. Everything else
will leave the version blank in `makedocs`, respectively require
explicitly setting `inventory_version` manually

* Update the CHANGELOG
@goerz goerz restored the mg/inventory-version-overwrite-in-deploydocs branch February 27, 2024 11:40
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.

None yet

1 participant