From 414599b386d99dd74544b46469f94e4b7e058c66 Mon Sep 17 00:00:00 2001 From: Sebastian Stock <42280794+sostock@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:04:41 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20use=20`@doc(=E2=80=A6)`=20to=20?= =?UTF-8?q?look=20up=20docstrings=20(#671)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Donā€™t use `@doc(ā€¦)` to look up docstrings * Simplify definition of liters * Add NEWS and release v1.16.1 --- NEWS.md | 4 ++++ Project.toml | 2 +- src/pkgdefaults.jl | 15 ++++----------- test/runtests.jl | 17 ++++++++++++++++- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9d66a19f..649d9e1f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # Unitful.jl changelog +## v1.16.1 (2023-08-02) + +* ![Enhancement:](https://img.shields.io/badge/-enhancement-blue) Replaced occurrences of single-argument `@doc` for duplicating docstrings, which could lead to errors when creating a Docker image with Julia 1.9 and Unitful ([#671](https://github.com/PainterQubits/Unitful.jl/pull/671)). + ## v1.16.0 (2023-08-01) * ![Feature:](https://img.shields.io/badge/-feature-green) The derived dimension `MolarMass` (`šŒ/š`) is added ([#663](https://github.com/PainterQubits/Unitful.jl/pull/663)). diff --git a/Project.toml b/Project.toml index 33363e7b..1778c7ea 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Unitful" uuid = "1986cc42-f94f-5a68-af5c-568840ba703d" -version = "1.16.0" +version = "1.16.1" [deps] ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9" diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 0a128eb8..66d04a9b 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -302,12 +302,7 @@ const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, š‹^2}(2, 1//1),), š‹^2}() \nThe liter, a metric unit of volume, defined as 1000 cm^3. \nDimension: š‹^3. \nSee Also: [`Unitful.cm`](@ref)." -@unit L "L" Liter m^3//1000 true -for p in (:y, :z, :a, :f, :p, :n, :Ī¼, :m, :c, :d, - Symbol(""), :da, :h, :k, :M, :G, :T, :P, :E, :Z, :Y) - Core.eval(Unitful, :(const $(Symbol(p,:l)) = $(Symbol(p,:L)))) -end -@doc @doc(L) l +((@unit L "L" Liter m^3//1000 true), const l = L) for (k,v) in prefixdict if k != 0 sym_L = Symbol(v,:L) @@ -322,7 +317,7 @@ for (k,v) in prefixdict See also: [`Unitful.L`](@ref). """ - run = quote @doc $docstring $sym_l; @doc $docstring $sym_L end + run = quote @doc $docstring ((const $sym_l = $sym_L), $sym_L) end eval(run) end end @@ -395,8 +390,7 @@ const Ī¼0 = 4Ļ€*(1//10)^7*H/m # exact (but gets promoted to Float64...), \nA quantity representing the vacuum permittivity constant, defined as 1 / (Ī¼0 Ɨ c^2). \nDimension: šˆ^2 š“^4 š‹^-3 šŒ^-1. \nSee also: [`Unitful.Ī¼0`](@ref), [`Unitful.c`](@ref)." -const Īµ0 = 1/(Ī¼0*c^2) # exact, electric constant; changes here may affect -@doc @doc(Īµ0) const Ļµ0 = Īµ0 # test of issue 79. +((const Īµ0 = 1/(Ī¼0*c^2)), const Ļµ0 = Īµ0) # exact, electric constant; changes here may affect test of issue 79. " Unitful.Z0 \nA quantity representing the impedance of free space, a constant defined as Ī¼0 Ɨ c. \nDimension: š‹^2 šŒ šˆ^-2 š“^-3. @@ -586,8 +580,7 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe angstrom, a metric unit of length defined as 1/10 nm. \nDimension: [`Unitful.š‹`](@ref). \nSee Also: [`Unitful.nm`](@ref)." -@unit angstrom "ƅ" Angstrom (1//10)*nm false -@doc @doc(angstrom) const ƅ = angstrom +((@unit angstrom "ƅ" Angstrom (1//10)*nm false), const ƅ = angstrom) # Area " Unitful.ac diff --git a/test/runtests.jl b/test/runtests.jl index 38d4c7e6..dc6ae66e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2057,12 +2057,23 @@ end @test uparse("ɛ0") === uparse("Īµ0") @test @doc(Unitful.ɛ0) == @doc(Unitful.Īµ0) # Julia treats ƅ (U+00C5) and ā„« (U+212B) as the same - @test Unitful.ƅ === Unitful.ā„« === Unitful.angstrom + @test Unitful.ƅ === Unitful.ā„« @test u"ƅ" === u"ā„«" @test uparse("ƅ") === uparse("ā„«") @test @doc(Unitful.ƅ) == @doc(Unitful.ā„«) end +@testset "Units aliases" begin + @test Unitful.L === Unitful.l + @test Unitful.mL === Unitful.ml + @test 1Unitful.L === 1Unitful.l + @test 2Unitful.mL === 2Unitful.ml + @test Unitful.Ļµ0 === Unitful.Īµ0 + @test (1//2)Unitful.Ļµ0 === (1//2)Unitful.Īµ0 + @test Unitful.ƅ === Unitful.angstrom + @test 1.0Unitful.ƅ === 1.0Unitful.angstrom +end + module DocUnits using Unitful using Unitful: š‹ @@ -2076,6 +2087,10 @@ module DocUnits end @testset "Docs" begin + @test string(@doc(Unitful.L)) == string(@doc(Unitful.l)) + @test string(@doc(Unitful.cL)) == string(@doc(Unitful.cl)) + @test string(@doc(Unitful.Ļµ0)) == string(@doc(Unitful.Īµ0)) + @test string(@doc(Unitful.ƅ)) == string(@doc(Unitful.angstrom)) @test string(@doc DocUnits.šƒ) == "dimension docs\n" @test string(@doc DocUnits.dRefFoo) == "refunit docs\n" @test string(@doc DocUnits.dFoo) == "unit docs\n"