diff --git a/src/deploydocs.jl b/src/deploydocs.jl index e33dfde922..a45dc734a8 100644 --- a/src/deploydocs.jl +++ b/src/deploydocs.jl @@ -273,7 +273,10 @@ function deploydocs(; inventory_version = _get_inventory_version(objects_inv) deploy_version = _get_deploy_version(deploy_subfolder) if !isempty(deploy_version) && (inventory_version != deploy_version) - error("Inventory declares version `$inventory_version`, but `deploydocs` is for version `$deploy_version`") + if !isempty(inventory_version) + @warn "Inventory declares version `$inventory_version`, but `deploydocs` is for version `$deploy_version`. Overwriting inventory version." + end + _patch_inventory_version(objects_inv, deploy_version) end end @debug "pushing new documentation to remote: '$deploy_repo:$deploy_branch'." @@ -303,6 +306,23 @@ function _get_inventory_version(objects_inv) end +function _patch_inventory_version(objects_inv, version) + objects_inv_patched = tempname() + open(objects_inv) do input + open(objects_inv_patched, "w") do output + for line in eachline(input; keep=true) + if startswith(line, "# Version:") + @debug "Patched $objects_inv with version=$version" + line = "# Version: $version\n" + end + write(output, line) + end + end + end + mv(objects_inv_patched, objects_inv; force=true) +end + + function _get_deploy_version(foldername) try return string(VersionNumber(foldername)) # strips the leading "v" from foldername diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index 7e9cce19a0..3bc80be668 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -55,7 +55,8 @@ The [format of the `objects.inv` file](https://juliadocs.org/DocInventories.jl/s is borrowed from the [Sphinx project](https://www.sphinx-doc.org/en/master/). It consists of a plain text header that includes the project name, taken from the `sitename` argument to [`Documenter.makedocs`](@ref), and a project `version` obtained from the closest -`Project.toml` or `VERSION` file. +`Project.toml`, `JuliaProject.toml`, or `VERSION` file that defines a `version`, +respectively from the deployment tag in [`Documenter.deploydocs`](@ref). The bulk of the file is a list of plain text records, compressed with gzip. See [Inventory Generation](http://juliadocs.org/DocumenterInterLinks.jl/stable/write_inventory/) diff --git a/test/deploydocs.jl b/test/deploydocs.jl index 2bc71745da..7b5c1f862d 100644 --- a/test/deploydocs.jl +++ b/test/deploydocs.jl @@ -33,15 +33,6 @@ Documenter.authenticated_repo_url(c::TestDeployConfig) = c.repo_path devbranch = "master", ) # Deploy 1.0.0 tag - @test_throws ErrorException("Inventory declares version ``, but `deploydocs` is for version `1.0.0`") begin - deploydocs( - root = pwd(), - deploy_config = TestDeployConfig(full_repo_path, "1.0.0"), - repo = full_repo_path, - devbranch = "master", - ) - end - DocInventories.save(objects_inv, Inventory(project="test", version="1.0.0")) @quietly deploydocs( root = pwd(), deploy_config = TestDeployConfig(full_repo_path, "1.0.0"), @@ -49,15 +40,9 @@ Documenter.authenticated_repo_url(c::TestDeployConfig) = c.repo_path devbranch = "master", ) # Deploy 1.1.0 tag - @test_throws ErrorException("Inventory declares version `1.0.0`, but `deploydocs` is for version `1.1.0`") begin - deploydocs( - root = pwd(), - deploy_config = TestDeployConfig(full_repo_path, "1.1.0"), - repo = full_repo_path, - devbranch = "master", - ) - end - DocInventories.save(objects_inv, Inventory(project="test", version="1.1.0")) + # (note that the inventory still declares 1.0.0 as the version, so + # this implicitly tests that `deploydocs` overwrites it with the + # correct version) @quietly deploydocs( root = pwd(), deploy_config = TestDeployConfig(full_repo_path, "1.1.0"),