From a776e81267c2517f8d2f28f2578b598c655787c2 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Fri, 13 Aug 2021 15:56:23 -0600 Subject: [PATCH 01/43] Unit construction macro now defines docs for units See #436 --- src/user.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/user.jl b/src/user.jl index 50a62783..50aaf69b 100644 --- a/src/user.jl +++ b/src/user.jl @@ -238,9 +238,15 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor) for (k,v) in prefixdict s = Symbol(v,symb) u = :($Unit{$n, $user_dimension}($k,1//1)) + docstring1 = "Equal to 10^"*string(k)*" "*string(name)*", or " + docstring2 = ", with dimensions "*string(eval(user_dimension)) ea = quote $(basefactors_expr(__module__, n, basefactor)) const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() + function Docs.getdoc(x::typeof($s)) + factor = uconvert(upreferred($s),1*$s) + $docstring1*string(factor)*$docstring2 + end end push!(expr.args, ea) end @@ -267,9 +273,15 @@ macro unit_symbols(symb,name,user_dimension,basefactor) s = Symbol(symb) n = Meta.quot(Symbol(name)) u = :($Unit{$n, $user_dimension}(0,1//1)) + docstring1 = "Defines the "*string(name)*" as " + docstring2 = ", with dimensions "*string(eval(user_dimension)) esc(quote $(basefactors_expr(__module__, n, basefactor)) const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() + function Docs.getdoc(x::typeof($s)) + factor = uconvert(upreferred($s),1*$s) + $docstring1*string(factor)*$docstring2 + end end) end From 204558a1806ba16e69569febfc7186a229376470 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 21 Aug 2021 20:29:52 -0600 Subject: [PATCH 02/43] Add documentation capabilities to most defined macros This lets all unit and dimension definition macros repect doc strings set in unit definition. Additionally, it automatically defines documentation for derived units using power-of-ten prefixes. --- src/user.jl | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/user.jl b/src/user.jl index 50aaf69b..b5dfe109 100644 --- a/src/user.jl +++ b/src/user.jl @@ -60,8 +60,8 @@ macro dimension(symb, abbr, name) funame = Symbol(name,"FreeUnits") esc(quote $Unitful.abbr(::$Dimension{$x}) = $abbr - const global $s = $Dimensions{($Dimension{$x}(1),)}() - const global ($name){T,U} = Union{ + Base.@__doc__ const global $s = $Dimensions{($Dimension{$x}(1),)}() + Base.@__doc__ const global ($name){T,U} = Union{ $Quantity{T,$s,U}, $Level{L,S,$Quantity{T,$s,U}} where {L,S}} const global ($uname){U} = $Units{U,$s} @@ -89,7 +89,7 @@ macro derived_dimension(name, dims) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") esc(quote - const global ($name){T,U} = Union{ + Base.@__doc__ const global ($name){T,U} = Union{ $Quantity{T,$dims,U}, $Level{L,S,$Quantity{T,$dims,U}} where {L,S}} const global ($uname){U} = $Units{U,$dims} @@ -138,11 +138,11 @@ macro refunit(symb, abbr, name, dimension, tf) if tf push!(expr.args, quote - $Unitful.@prefixed_unit_symbols $symb $name $dimension (1.0, 1) + Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $dimension (1.0, 1) end) else push!(expr.args, quote - $Unitful.@unit_symbols $symb $name $dimension (1.0, 1) + Base.@__doc__ $Unitful.@unit_symbols $symb $name $dimension (1.0, 1) end) end @@ -180,11 +180,11 @@ macro unit(symb,abbr,name,equals,tf) if tf push!(expr.args, quote - $Unitful.@prefixed_unit_symbols $symb $name $d $basef + Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $d $basef end) else push!(expr.args, quote - $Unitful.@unit_symbols $symb $name $d $basef + Base.@__doc__ $Unitful.@unit_symbols $symb $name $d $basef end) end @@ -204,7 +204,7 @@ in terms of an absolute scale; the scaling is the same as the absolute scale. Ex macro affineunit(symb, abbr, offset) s = Symbol(symb) return esc(quote - const global $s = $affineunit($offset) + Base.@__doc__ const global $s = $affineunit($offset) $Base.show(io::$IO, ::$genericunit($s)) = $print(io, $abbr) end) end @@ -238,14 +238,16 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor) for (k,v) in prefixdict s = Symbol(v,symb) u = :($Unit{$n, $user_dimension}($k,1//1)) - docstring1 = "Equal to 10^"*string(k)*" "*string(name)*", or " - docstring2 = ", with dimensions "*string(eval(user_dimension)) + isbase = k==0 + docstring1 = "Unit equal to 10^"*string(k)*" "*string(symb)*"." + docstring1 *= "\n\nSee also: [`Unitful."*string(symb)*"`](@ref)" ea = quote $(basefactors_expr(__module__, n, basefactor)) const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() - function Docs.getdoc(x::typeof($s)) - factor = uconvert(upreferred($s),1*$s) - $docstring1*string(factor)*$docstring2 + if ($isbase) + Base.@__doc__ $s + else + @doc $docstring1 $s end end push!(expr.args, ea) @@ -273,15 +275,9 @@ macro unit_symbols(symb,name,user_dimension,basefactor) s = Symbol(symb) n = Meta.quot(Symbol(name)) u = :($Unit{$n, $user_dimension}(0,1//1)) - docstring1 = "Defines the "*string(name)*" as " - docstring2 = ", with dimensions "*string(eval(user_dimension)) esc(quote $(basefactors_expr(__module__, n, basefactor)) - const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() - function Docs.getdoc(x::typeof($s)) - factor = uconvert(upreferred($s),1*$s) - $docstring1*string(factor)*$docstring2 - end + Base.@__doc__ const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() end) end @@ -409,7 +405,7 @@ macro logscale(symb,abbr,name,base,prefactor,irp) const global $(esc(Symbol(symb,"_rp"))) = MixedUnits{Gain{$(esc(name)), :rp}}() const global $(esc(Symbol(symb,"_p"))) = MixedUnits{Gain{$(esc(name)), :p}}() - macro $(esc(symb))(::Union{Real,Symbol}) + Base.@__doc__ macro $(esc(symb))(::Union{Real,Symbol}) throw(ArgumentError(join(["usage: `@", $(String(symb)), " (a)/(b)`"]))) end @@ -466,7 +462,7 @@ Defines a logarithmic unit. For examples see `src/pkgdefaults.jl`. macro logunit(symb, abbr, logscale, reflevel) quote $Unitful.abbr(::Level{$(esc(logscale)), $(esc(reflevel))}) = $abbr - const global $(esc(symb)) = + Base.@__doc__ const global $(esc(symb)) = MixedUnits{Level{$(esc(logscale)), $(esc(reflevel))}}() end end From 8edfd218dbac68d27d17b4e29ef512b9ed2a3a9d Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 21 Aug 2021 20:30:58 -0600 Subject: [PATCH 03/43] Add documentation for some units in pkgdefaults Documentation has been added for all base units and many other SI units, as well as adding a special case to the documentation so that kg and documented as being the SI base unit. --- src/pkgdefaults.jl | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 56a1dbfd..f387045a 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -53,17 +53,27 @@ const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T # Define base units. This is not to imply g is the base SI unit instead of kg. # See the documentation for further details. # #key: Symbol Display Name Dimension Prefixes? +"SI Unit of length\n\nSee also: [`Unitful.๐‹`](@ref)" @refunit m "m" Meter ๐‹ true +"SI Unit of time\n\nSee also: [`Unitful.๐“`](@ref)" @refunit s "s" Second ๐“ true +"SI Unit of current\n\nSee also: [`Unitful.๐ˆ`](@ref)" @refunit A "A" Ampere ๐ˆ true +"SI Unit of temperature\n\nSee also: [`Unitful.๐šฏ`](@ref)" @refunit K "K" Kelvin ๐šฏ true +"SI Unit of luminosity\n\nSee also: [`Unitful.๐‰`](@ref)" @refunit cd "cd" Candela ๐‰ true +# the docs for all gram-based units are defined later, to ensure kg is the base unit. @refunit g "g" Gram ๐Œ true +"SI Unit for amounts of a substance\n\nSee also: [`Unitful.๐`](@ref)" @refunit mol "mol" Mole ๐ true # Angles and solid angles +"Unit of spherical angle. There are 4ฯ€ sr in a sphere." @unit sr "sr" Steradian 1 true +"Unit of angle. There are 2ฯ€ rad in a circle." @unit rad "rad" Radian 1 true +"Unit of angle. There are 360ยฐ in a circle." @unit ยฐ "ยฐ" Degree pi/180 false # For numerical accuracy, specific to the degree import Base: sind, cosd, tand, secd, cscd, cotd @@ -79,30 +89,49 @@ deg2rad(d::Quantity{T, NoDims, typeof(ยฐ)}) where {T} = deg2rad(ustrip(ยฐ, d))u" rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r))u"ยฐ" # SI and related units +"SI Unit of frequency, defined as 1/s\n\nSee also: [`Unitful.s`](@ref)" @unit Hz "Hz" Hertz 1/s true +"SI Unit of force, defined as 1kg*m/s^2\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.s`](@ref)" @unit N "N" Newton 1kg*m/s^2 true +"SI Unit of pressure, defined as 1N/m^2\n\nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)" @unit Pa "Pa" Pascal 1N/m^2 true +"SI Unit of energy, defined as 1N*m\n\nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)" @unit J "J" Joule 1N*m true +"SI Unit of power, defined as 1J/s\n\nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)" @unit W "W" Watt 1J/s true +"SI Unit of electric charge, defined as 1A*s\n\nSee also: [`Unitful.A`](@ref), [`Unitful.s`](@ref)" @unit C "C" Coulomb 1A*s true +"SI Unit of electric potential, defined as 1W/A\n\nSee also: [`Unitful.W`](@ref), [`Unitful.A`](@ref)" @unit V "V" Volt 1W/A true +"SI Unit of electrical resistance, defined as 1V/A\n\nSee also: [`Unitful.V`](@ref), [`Unitful.A`](@ref)" @unit ฮฉ "ฮฉ" Ohm 1V/A true +"SI Unit of electrical conductance, defined as 1/ฮฉ\n\nSee also: [`Unitful.ฮฉ`](@ref)" @unit S "S" Siemens 1/ฮฉ true +"SI Unit of electrical capacitance, defined as 1s^4*A^2/(kg*m^2)\n\nSee also: [`Unitful.s`](@ref), [`Unitful.A`](@ref), [`Unitful.kg`](@ref), [`Unitful.m`](@ref)" @unit F "F" Farad 1s^4*A^2/(kg*m^2) true +"SI Unit of electrical inductance, defined as 1J/(A^2)\n\nSee also: [`Unitful.J`](@ref), [`Unitful.A`](@ref)" @unit H "H" Henry 1J/(A^2) true +"SI Unit of magnetic B-field strength, defined as 1kg/(A*s^2)\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)" @unit T "T" Tesla 1kg/(A*s^2) true +"SI Unit of magnetic flux, defined as 1kg*m^2/(A*s^2)\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)" @unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true +"SI Unit of luminous flux, defined as 1cd*sr\n\nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)" @unit lm "lm" Lumen 1cd*sr true +"SI Unit of illuminance, defined as 1lm/m^2\n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)" @unit lx "lx" Lux 1lm/m^2 true @unit Bq "Bq" Becquerel 1/s true @unit Gy "Gy" Gray 1J/kg true @unit Sv "Sv" Sievert 1J/kg true @unit kat "kat" Katal 1mol/s true +"Unit meaning parts per hundred" @unit percent "%" Percent 1//100 false +"Unit meaning parts per thousand" @unit permille "โ€ฐ" Permille 1//1000 false +"Unit meaning parts per ten thousand" @unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false # Temperature +"SI Unit of temperature, defined such that 0ยฐC = 273.15K\n\nSee also: [`Unitful.K`](@ref)" @affineunit ยฐC "ยฐC" (27315//100)K # Common units of time @@ -295,6 +324,18 @@ end ######### preferunits(kg) # others done in @refunit +# Fix documentation for all kg based units +# Using a NullLogger is necessary to avoid documentation overwritten errors. +Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do + for (k,v) in prefixdict + sym = Symbol(v,:g) + docstring = "Unit equal to 10^"*string(k-3)*" kg." + docstring *= "\n\nSee also: [`Unitful.kg`](@ref)" + run = quote @doc $docstring $sym end + eval(run) + end + @doc "SI Unit of mass\n\nSee also: [`Unitful.๐Œ`](@ref)" kg +end """ Unitful.promote_to_derived() From f555097f94279055ab3f020759083414b99ae160 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 21 Aug 2021 20:51:00 -0600 Subject: [PATCH 04/43] Allow documentation for log scales and units --- src/user.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/user.jl b/src/user.jl index b5dfe109..3a3df366 100644 --- a/src/user.jl +++ b/src/user.jl @@ -401,7 +401,7 @@ macro logscale(symb,abbr,name,base,prefactor,irp) const global $(esc(name)) = LogInfo{$(QuoteNode(name)), $base, $prefactor} $Unitful.isrootpower(::Type{$(esc(name))}) = $irp - const global $(esc(symb)) = MixedUnits{Gain{$(esc(name)), :?}}() + Base.@__doc__ const global $(esc(symb)) = MixedUnits{Gain{$(esc(name)), :?}}() const global $(esc(Symbol(symb,"_rp"))) = MixedUnits{Gain{$(esc(name)), :rp}}() const global $(esc(Symbol(symb,"_p"))) = MixedUnits{Gain{$(esc(name)), :p}}() @@ -434,7 +434,7 @@ macro logscale(symb,abbr,name,base,prefactor,irp) return Level{$(esc(name)), den}(num) end - function (::$(esc(:typeof))($(esc(symb))))(num::Number, den::Number, irp::Bool) + Base.@__doc__ function (::$(esc(:typeof))($(esc(symb))))(num::Number, den::Number, irp::Bool) dimension(num) != dimension(den) && throw(DimensionError(num,den)) dimension(num) != NoDims && throw(ArgumentError(string("when passing a final Bool argument, ", From 59b4e972548a234f3b824280694f65b907d16f9f Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Tue, 5 Oct 2021 15:58:42 -0500 Subject: [PATCH 05/43] Rewrite documentation format for all units through "Liter" Additionally, changed how the prefixed unit documentation is written; this now means that prefixed units made by other modules should be properly documented (tested with UnitfulAstro). --- src/pkgdefaults.jl | 154 ++++++++++++++++++++++++++++++++++++--------- src/user.jl | 4 +- 2 files changed, 125 insertions(+), 33 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index f387045a..cbaf1b01 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -53,27 +53,33 @@ const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T # Define base units. This is not to imply g is the base SI unit instead of kg. # See the documentation for further details. # #key: Symbol Display Name Dimension Prefixes? -"SI Unit of length\n\nSee also: [`Unitful.๐‹`](@ref)" +"The meter, the base SI unit of length. +\n\nDimension: [`Unitful.๐‹`](@ref)." @refunit m "m" Meter ๐‹ true -"SI Unit of time\n\nSee also: [`Unitful.๐“`](@ref)" +"The second, the base SI unit of time. +\n\nDimension: [`Unitful.๐“`](@ref)." @refunit s "s" Second ๐“ true -"SI Unit of current\n\nSee also: [`Unitful.๐ˆ`](@ref)" +"The ampere, the base SI unit of current. +\n\nDimension: [`Unitful.๐ˆ`](@ref)." @refunit A "A" Ampere ๐ˆ true -"SI Unit of temperature\n\nSee also: [`Unitful.๐šฏ`](@ref)" +"The kelvin, the base SI unit of temperature. +\n\nDimension: [`Unitful.๐šฏ`](@ref)." @refunit K "K" Kelvin ๐šฏ true -"SI Unit of luminosity\n\nSee also: [`Unitful.๐‰`](@ref)" +"The candela, the base SI unit of luminosity. +\n\nDimension: [`Unitful.๐‰`](@ref)." @refunit cd "cd" Candela ๐‰ true # the docs for all gram-based units are defined later, to ensure kg is the base unit. @refunit g "g" Gram ๐Œ true -"SI Unit for amounts of a substance\n\nSee also: [`Unitful.๐`](@ref)" +"The mol, the base SI unit for amounts of a substance. +\n\nDimension: [`Unitful.๐`](@ref)." @refunit mol "mol" Mole ๐ true # Angles and solid angles -"Unit of spherical angle. There are 4ฯ€ sr in a sphere." +"The steradian, a unit of spherical angle. There are 4ฯ€ sr in a sphere." @unit sr "sr" Steradian 1 true -"Unit of angle. There are 2ฯ€ rad in a circle." +"The radian, a unit of angle. There are 2ฯ€ rad in a circle." @unit rad "rad" Radian 1 true -"Unit of angle. There are 360ยฐ in a circle." +"The degree, a unit of angle. There are 360ยฐ in a circle." @unit ยฐ "ยฐ" Degree pi/180 false # For numerical accuracy, specific to the degree import Base: sind, cosd, tand, secd, cscd, cotd @@ -89,72 +95,155 @@ deg2rad(d::Quantity{T, NoDims, typeof(ยฐ)}) where {T} = deg2rad(ustrip(ยฐ, d))u" rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r))u"ยฐ" # SI and related units -"SI Unit of frequency, defined as 1/s\n\nSee also: [`Unitful.s`](@ref)" +"The hertz, an SI unit of frequency, defined as 1/s. +\n\nDimension: ๐“^-1. +\n\nSee also: [`Unitful.s`](@ref)." @unit Hz "Hz" Hertz 1/s true -"SI Unit of force, defined as 1kg*m/s^2\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.s`](@ref)" +"The newton, an SI unit of force, defined as 1kg*m/s^2. +\n\nDimension: ๐‹ ๐Œ ๐“^-2. +\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit N "N" Newton 1kg*m/s^2 true -"SI Unit of pressure, defined as 1N/m^2\n\nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)" +"The pascal, an SI unit of pressure, defined as 1N/m^2. +\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\n\nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." @unit Pa "Pa" Pascal 1N/m^2 true -"SI Unit of energy, defined as 1N*m\n\nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)" +"The joule, an SI unit of energy, defined as 1N*m. +\n\nDimension: ๐‹^2 ๐Œ ๐“^-2. +\n\nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." @unit J "J" Joule 1N*m true -"SI Unit of power, defined as 1J/s\n\nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)" +"The watt, an SI unit of power, defined as 1J/s. +\n\nDimension: ๐‹^2 ๐Œ ๐“^-3. +\n\nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." @unit W "W" Watt 1J/s true -"SI Unit of electric charge, defined as 1A*s\n\nSee also: [`Unitful.A`](@ref), [`Unitful.s`](@ref)" +"The coulomb, an SI unit of electric charge, defined as 1A*s. +\n\nDimension: ๐ˆ ๐“. +\n\nSee also: [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit C "C" Coulomb 1A*s true -"SI Unit of electric potential, defined as 1W/A\n\nSee also: [`Unitful.W`](@ref), [`Unitful.A`](@ref)" +"The volt, an SI unit of electric potential, defined as 1W/A. +\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-3. +\n\nSee also: [`Unitful.W`](@ref), [`Unitful.A`](@ref)" @unit V "V" Volt 1W/A true -"SI Unit of electrical resistance, defined as 1V/A\n\nSee also: [`Unitful.V`](@ref), [`Unitful.A`](@ref)" +"The ohm, an SI unit of electrical resistance, defined as 1V/A. +\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. +\n\nSee also: [`Unitful.V`](@ref), [`Unitful.A`](@ref)." @unit ฮฉ "ฮฉ" Ohm 1V/A true -"SI Unit of electrical conductance, defined as 1/ฮฉ\n\nSee also: [`Unitful.ฮฉ`](@ref)" +"The siemens, an SI unit of electrical conductance, defined as 1/ฮฉ. +\n\nDimension: ๐ˆ^2 ๐“^3 ๐‹^-2 ๐Œ^-1. +\n\nSee also: [`Unitful.ฮฉ`](@ref)" @unit S "S" Siemens 1/ฮฉ true -"SI Unit of electrical capacitance, defined as 1s^4*A^2/(kg*m^2)\n\nSee also: [`Unitful.s`](@ref), [`Unitful.A`](@ref), [`Unitful.kg`](@ref), [`Unitful.m`](@ref)" +"The farad, an SI unit of electrical capacitance, defined as 1s^4*A^2/(kg*m^2). +\n\nDimension: ๐ˆ^2 ๐“^4 ๐‹^-2 ๐Œ^-1. +\n\nSee also: [`Unitful.s`](@ref), [`Unitful.A`](@ref), [`Unitful.kg`](@ref), [`Unitful.m`](@ref)." @unit F "F" Farad 1s^4*A^2/(kg*m^2) true -"SI Unit of electrical inductance, defined as 1J/(A^2)\n\nSee also: [`Unitful.J`](@ref), [`Unitful.A`](@ref)" +"The henry, an SI unit of electrical inductance, defined as 1J/(A^2). +\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-2. +\n\nSee also: [`Unitful.J`](@ref), [`Unitful.A`](@ref)." @unit H "H" Henry 1J/(A^2) true -"SI Unit of magnetic B-field strength, defined as 1kg/(A*s^2)\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)" +"The tesla, an SI unit of magnetic B-field strength, defined as 1kg/(A*s^2). +\n\nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. +\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit T "T" Tesla 1kg/(A*s^2) true -"SI Unit of magnetic flux, defined as 1kg*m^2/(A*s^2)\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)" +"The weber, an SI unit of magnetic flux, defined as 1kg*m^2/(A*s^2). +\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. +\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true -"SI Unit of luminous flux, defined as 1cd*sr\n\nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)" +"The lumen, an SI unit of luminous flux, defined as 1cd*sr. +\n\nDimension: ๐‰. +\n\nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)." @unit lm "lm" Lumen 1cd*sr true -"SI Unit of illuminance, defined as 1lm/m^2\n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)" +"The lux, an SI unit of illuminance, defined as 1lm/m^2. +\n\nDimension: ๐‰ ๐‹^-2. +\n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit lx "lx" Lux 1lm/m^2 true +"The becquerel, an SI unit of radioactivity, defined as 1 nuclear decay per s. +\n\nDimension: ๐“^-1. +\n\nSee also: [`Unitful.s`](@ref)." @unit Bq "Bq" Becquerel 1/s true +"The gray, an SI unit of ionizing radiation dose, defined as the absorbtion of 1J per kg of matter. +\n\nDimension: ๐‹^2 ๐“^-2. +\n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit Gy "Gy" Gray 1J/kg true +"The sievert, an SI unit of the biological effect of an ionizing radiation dose. +Defined as the health effect of 1Sv of radiation, scaled based on a quality factor. +\n\nDimension: ๐‹^2 ๐“^-2. +\n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit Sv "Sv" Sievert 1J/kg true +"The katal, an SI unit of catalytic activity, defined as 1mol of catalyzed +substrate per s. +\n\nDimension: ๐ ๐“^-1. +\n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit kat "kat" Katal 1mol/s true -"Unit meaning parts per hundred" +"Percent, a unit meaning parts per hundred." @unit percent "%" Percent 1//100 false -"Unit meaning parts per thousand" +"Permille, a unit meaning parts per thousand." @unit permille "โ€ฐ" Permille 1//1000 false -"Unit meaning parts per ten thousand" +"Permyriad, a unit meaning parts per ten thousand." @unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false # Temperature -"SI Unit of temperature, defined such that 0ยฐC = 273.15K\n\nSee also: [`Unitful.K`](@ref)" +"Celcius, an SI unit of temperature, defined such that 0ยฐC = 273.15K. +\n\nDimension: [`Unitful.๐šฏ`](@ref). +\n\nSee also: [`Unitful.K`](@ref)." @affineunit ยฐC "ยฐC" (27315//100)K # Common units of time +"The minute, a unit of time defined as 60s. +\n\nDimension: [`Unitful.๐“`](@ref). +\n\nSee Also: [`Unitful.s`](@ref)." @unit minute "minute" Minute 60s false +"The hour, a unit of time defined as 60 minutes. +\n\nDimension: [`Unitful.๐“`](@ref). +\n\nSee Also: [`Unitful.minute`](@ref)." @unit hr "hr" Hour 3600s false +"The day, a unit of time defined as 24hr. +\n\nDimension: [`Unitful.๐“`](@ref). +\n\nSee Also: [`Unitful.hr`](@ref)." @unit d "d" Day 86400s false +"The week, a unit of time, defined as 70d. +\n\nDimension: [`Unitful.๐“`](@ref). +\n\nSee Also: [`Unitful.d`](@ref)." @unit wk "wk" Week 604800s false +"The year, a unit of time, defined as 8766hr. +\n\nDimension: [`Unitful.๐“`](@ref). +\n\nSee Also: [`Unitful.hr`](@ref)." @unit yr "yr" Year 31557600s true +"Revolutions per second, a unit of rotational speed, defined as one rotation per s. +\n\nDimension: ๐“^-1. +\n\nSee Also: [`Unitful.s`](@ref)." @unit rps "rps" RevolutionsPerSecond 2ฯ€*rad/s false +"Revolutions per minute, a unit of rotational speed, defined as one rotation per minute. +\n\nDimension: ๐“^-1. +\n\nSee Also: [`Unitful.minute`](@ref)." @unit rpm "rpm" RevolutionsPerMinute 2ฯ€*rad/minute false # Area # The hectare is used more frequently than any other power-of-ten of an are. +"The are, a metric unit of area, defined as 100m^2. +\n\nDimension: ๐‹^2. +\n\nSee Also: [`Unitful.m`](@ref)." @unit a "a" Are 100m^2 false +"The hectare, a metric unit of area, defined as 100a. +\n\nDimension: ๐‹^2. +\n\nSee Also: [`Unitful.a`](@ref)." const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, ๐‹^2}(2, 1//1),), ๐‹^2}() +"The barn, a metric unit of area, defined as 100fm^2. +\n\nDimension: ๐‹^2. +\n\nSee Also: [`Unitful.fm`](@ref)." @unit b "b" Barn 100fm^2 true # Volume # `l` is also an acceptable symbol for liters +"The liter, a metric unit of volume, defined as 1000cm^2. +\n\nDimension: ๐‹^2. +\n\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)))) + # NullLogger to ignore documentation overwrite errors + Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do + Core.eval(Unitful, :(@doc @doc($(Symbol(p,:L))) $(Symbol(p,:l)))) + end end # Molarity @@ -329,12 +418,15 @@ preferunits(kg) # others done in @refunit Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do for (k,v) in prefixdict sym = Symbol(v,:g) - docstring = "Unit equal to 10^"*string(k-3)*" kg." - docstring *= "\n\nSee also: [`Unitful.kg`](@ref)" + docstring = "A prefixed unit, equal to 10^"*string(k-3)*" kg." + docstring *= " Note that `kg`, not `g`, is the base unit." + docstring *= "\n\nSee also: [`Unitful.kg`](@ref)." run = quote @doc $docstring $sym end eval(run) end - @doc "SI Unit of mass\n\nSee also: [`Unitful.๐Œ`](@ref)" kg + @doc "The kilogram, base SI unit of mass. + Note that `kg`, not `g`, is the base unit. + \n\nDimension: [`Unitful.๐Œ`](@ref)." kg end """ diff --git a/src/user.jl b/src/user.jl index 3a3df366..b0447d42 100644 --- a/src/user.jl +++ b/src/user.jl @@ -239,8 +239,8 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor) s = Symbol(v,symb) u = :($Unit{$n, $user_dimension}($k,1//1)) isbase = k==0 - docstring1 = "Unit equal to 10^"*string(k)*" "*string(symb)*"." - docstring1 *= "\n\nSee also: [`Unitful."*string(symb)*"`](@ref)" + docstring1 = "A prefixed unit, equal to 10^"*string(k)*" "*string(symb)*"." + docstring1 *= "\n\nSee also: [`"*string(__module__)*"."*string(symb)*"`](@ref)." ea = quote $(basefactors_expr(__module__, n, basefactor)) const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() From 0184346cacfd1eaeb9ac41b77c0c7b34394be1e5 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Wed, 6 Oct 2021 22:46:27 -0500 Subject: [PATCH 06/43] Added documentation for all remaining units Documentation is still required for log scales --- src/pkgdefaults.jl | 186 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index cbaf1b01..ab6690a3 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -2,12 +2,19 @@ # The dimension symbols are generated by tab completion: \bfL is ๐‹, etc. # At the expense of easy typing, this gives a visual cue to distinguish # dimensions from units, and also helps prevent common namespace collisions. +"A dimension representing length." @dimension ๐‹ "๐‹" Length +"A dimension representing mass." @dimension ๐Œ "๐Œ" Mass +"A dimension representing time." @dimension ๐“ "๐“" Time +"A dimension representing current." @dimension ๐ˆ "๐ˆ" Current +"A dimension representing temperature." @dimension ๐šฏ "๐šฏ" Temperature # This one is \bfTheta +"A dimension representing luminosity." @dimension ๐‰ "๐‰" Luminosity +"A dimension representing amounts." @dimension ๐ "๐" Amount const RelativeScaleTemperature = Quantity{T, ๐šฏ, <:AffineUnits} where T const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T @@ -247,56 +254,181 @@ for p in (:y, :z, :a, :f, :p, :n, :ฮผ, :ยต, :m, :c, :d, end # Molarity +"A unit for measuring molar concentration, a 1 molar solution has 1 mol of +solute per L of solution. +\n\nDimension: ๐ ๐‹^-3. +\n\nSee Also: [`Unitful.L`](@ref), [`Unitful.mol`](@ref)." @unit M "M" Molar 1mol/L true # Energy +"A quantity equal to the elementary charge, the charge of a single electron, +with a value of exactly 1.602176634 e-19 C. +\n\nDimension: ๐ˆ ๐“. +\n\nSee Also: [`Unitful.C`](@ref)." const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... +"The electron-volt, a unit of energy, defined as q*V. +\n\nDimension: ๐‹^2 ๐Œ ๐“^-2. +\n\nSee also: [`Unitful.q`](@ref), [`Unitful.V`](@ref)." @unit eV "eV" eV q*V true # For convenience +"A unit for convinience in angular frequency, equal to 2ฯ€ Hz. +\n\nDimension: ๐“^-1. +\n\nSee also: [`Unitful.Hz`](@ref)." @unit Hz2ฯ€ "Hz2ฯ€" AngHertz 2ฯ€/s true +"The bar, a metric unit of pressure, defined as 100 kPa. +\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\n\nSee also: [`Unitful.kPa`](@ref)." @unit bar "bar" Bar 100000Pa true +"The standard atmosphere, a unit of pressure, defined as 101,325 Pa. +\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\n\nSee also: [`Unitful.Pa`](@ref)." @unit atm "atm" Atmosphere 101325Pa false +"The torr, a unit of pressure, defined as 1//760 atm. +\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\n\nSee also: [`Unitful.atm`](@ref)." @unit Torr "Torr" Torr 101325Pa//760 true # Constants (2018 CODATA values) (uncertainties in final digits) +"A quantity representing the speed of light in a vacuum, defined as exactly +299,792,458 m/s. +\n\nDimension: ๐‹ ๐“^-1. +\n\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const c0 = 299_792_458*m/s # exact +"The speed of light in a vacuum, a unit of speed, defined as exactly +299,792,458 m/s. +\n\nDimension: ๐‹ ๐“^-1. +\n\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit c "c" SpeedOfLight 1c0 false +"A quantity representing the vacuum permeability constant, defined as 4ฯ€ * 1e-7 H/m. +\n\nDimension: ๐‹ ๐Œ ๐ˆ^-2 ๐“^-2. +\n\nSee also: [`Unitful.H`](@ref), [`Unitful.m`](@ref)." const ฮผ0 = 4ฯ€*(1//10)^7*H/m # exact (but gets promoted to Float64...) const ยต0 = ฮผ0 # magnetic constant +"A quantity representing the vacuum permittivity constant, defined as 1/(ฮผ0*c^2). +\n\nDimension: ๐ˆ^2 ๐“^4 ๐‹^-3 ๐Œ^-1. +\n\nSee also: [`Unitful.ฮผ0`](@ref), [`Unitful.c`](@ref)." const ษ›0 = 1/(ฮผ0*c^2) # exact, electric constant; changes here may affect const ฯต0 = ษ›0 # test of issue 79. +"A quantity representing the impedance of free space, a constant defined as ฮผ0*c. +\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. +\n\nSee also: [`Unitful.ฮผ0`](@ref), [`Unitful.c`](@ref)." const Z0 = ฮผ0*c # exact, impedance of free space +"A quantity representing the universal gravitational constant. +\n\nDimension: ๐‹^3 ๐Œ^-1 ๐“^-2. +\n\nSee also: [`Unitful.m`](@ref), [`Unitful.kg`](@ref), [`Unitful.s`](@ref)." const G = 6.674_30e-11*m^3/kg/s^2 # (15) gravitational constant +"A quantity representing the nominal acceleration due to gravity in a vacuum +near the surface of the earth, defined by standard to be exactly 9.80665 m/s^2. +\n\nDimension: ๐‹ ๐“^-2. +\n\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const gn = 9.80665*m/s^2 # exact, standard acceleration of gravity +"A quantity representing Planck's constant, defined as exactly +6.62607015 e-34 J*s. +\n\nDimension: ๐‹^2 ๐Œ ๐“^-1. +\n\nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." const h = 6.626_070_15e-34*J*s # exact, Planck constant +"A quantity representing the reduced Planck constant, defined as h/(2ฯ€). +\n\nDimension: ๐‹^2 ๐Œ ๐“^-1. +\n\nSee also: [`Unitful.h`](@ref)." const ฤง = h/2ฯ€ # hbar +"A quantity representing the superconducting magnetic flux quantum, defined as +h/(2q). +\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. +\n\nSee also: [`Unitful.h`](@ref), [`Unitful.q`](@ref)." const ฮฆ0 = h/(2q) # Superconducting magnetic flux quantum +"A quantity representing the rest mass of an electron, given to 11 significant figures. +\n\nDimension: ๐Œ. +\n\nSee also: [`Unitful.kg`](@ref)." const me = 9.109_383_7015e-31*kg # (28) electron rest mass +"A quantity representing the rest mass of a neutron, given to 12 significant figures. +\n\nDimension: ๐Œ. +\n\nSee also: [`Unitful.kg`](@ref)." const mn = 1.674_927_498_04e-27*kg # (95) neutron rest mass +"A quantity representing the rest mass of a proton, given to 12 significant figures. +\n\nDimension: ๐Œ. +\n\nSee also: [`Unitful.kg`](@ref)." const mp = 1.672_621_923_69e-27*kg # (51) proton rest mass +"A quantity representing the Bohr magneton, given to 11 significant figures. +\n\nDimension: ๐ˆ ๐‹^2. +\n\nSee also: [`Unitful.q`](@ref), [`Unitful.ฤง`](@ref), [`Unitful.me`](@ref)." const ฮผB = q*ฤง/(2*me) # Bohr magneton const ยตB = ฮผB +"A quantity representing Avogadro's constant, defined as exactly +6.02214076 e23 / mol. +\n\nDimension: ๐^-1. +\n\nSee also: [`Unitful.mol`](@ref)." const Na = 6.022_140_76e23/mol # exact, Avogadro constant +"A quantity representing the Boltzmann constant, defined as exactly +1.380649 e-23 J/K. +\n\nDimension: ๐‹^2 ๐Œ ๐šฏ^-1 ๐“^-2. +\n\nSee also: [`Unitful.J`](@ref), [`Unitful.K`](@ref)." const k = 1.380_649e-23*(J/K) # exact, Boltzmann constant +"A quantity representing the molar gas constant, defined as +Na*k. +\n\nDimension: ๐‹^2 ๐Œ ๐^-1 ๐šฏ^-1 ๐“^-2. +\n\nSee also: [`Unitful.Na`](@ref), [`Unitful.k`](@ref)." const R = Na*k # molar gas constant +"A quantity representing the Stefan-Boltzmann constant, defined as +ฯ€^2*k^4/(60*ฤง^3*c^2). +\n\nDimension: ๐Œ ๐šฏ^-4 ๐“^-3. +\n\nSee also: [`Unitful.k`](@ref), [`Unitful.ฤง`](@ref), [`Unitful.c`](@ref)." const ฯƒ = ฯ€^2*k^4/(60*ฤง^3*c^2) # Stefan-Boltzmann constant +"A quantity representing the Bohr magneton, given to 14 significant figures. +\n\nDimension: ๐‹^-1. +\n\nSee also: [`Unitful.m`](@ref)." const Rโˆž = 10_973_731.568_160/m # (21) Rydberg constant +"The unifided atomic mass unit, or dalton, a unit of mass defined as 1//12 the +mass of an unbound neutral atom of carbon-12. It is defined here to 12 +significant figures. +\n\nDimension: [`Unitful.๐Œ`](@ref). +\n\nSee Also: [`Unitful.kg`](@ref)." @unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false # (50) # Acceleration +"The nominal acceleration due to gravity in a vacuum near the surface of the +earth, a unit of acceleration, defined by standard to be exactly 9.80665 m/s^2. +\n\nDimension: ๐‹ ๐“^-2. +\n\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit ge "ge" EarthGravity gn false # CGS units +"The gal, a CGS unit of acceleration, defined as 1cm/s^2. +\n\nDimension: ๐‹ ๐“^-2. +\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)." @unit Gal "Gal" Gal 1cm/s^2 true +"The dyne, a CGS unit of force, defined as 1g*cm/s^2. +\n\nDimension: ๐‹ ๐Œ ๐“^-2. +\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref), [`Unitful.g`](@ref)." @unit dyn "dyn" Dyne 1g*cm/s^2 true +"The erg, a CGS unit of energy, defined as 1dyn*cm. +\n\nDimension: ๐‹^2 ๐Œ ๐“^-2. +\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" @unit erg "erg" Erg 1g*cm^2/s^2 true +"The barye, a CGS unit of pressure, defined as 1dyn/cm^2. +\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" @unit Ba "Ba" Barye 1g/cm/s^2 true +"The poise, a CGS unit of dynamic viscosity, defined as 1dyn*s/cm^2. +\n\nDimension: ๐Œ ๐‹^-1 ๐“^-1. +\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref), [`Unitful.s`](@ref)" @unit P "P" Poise 1g/cm/s true +"The stokes, a CGS unit of kinematic viscosity, defined as 1cm^2/s. +\n\nDimension: ๐Œ^2 ๐“^-1. +\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)" @unit St "St" Stokes 1cm^2/s true +"The gauss, a CGS unit of magnetic B-field strength, defined as 1Mx/cm^2. +\n\nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. +\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.mx`](@ref)" @unit Gauss "Gauss" Gauss (1//10_000)*T true +"The oersted, a CGS unit of magnetic H-field strength, defined as (1_000/4ฯ€)A/m. +\n\nDimension: ๐ˆ ๐‹^-1. +\n\nSee also: [`Unitful.A`](@ref), [`Unitful.m`](@ref)" @unit Oe "Oe" Oersted (1_000/4ฯ€)*A/m true +"The maxwell, a CGS unit of magnetic flux, defined as 1Gauss*cm^2. +\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. +\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.Gauss`](@ref)" @unit Mx "Mx" Maxwell (1//100_000_000)*Wb true @@ -305,38 +437,92 @@ const Rโˆž = 10_973_731.568_160/m # (21) Rydberg constant # Length #key: Symbol Display Name Equivalent to 10^n prefixes? +"The inch, a US customary unit of length defined as 254//10000 m. +\n\nDimension: [`Unitful.๐‹`](@ref). +\n\nSee Also: [`Unitful.m`](@ref)." @unit inch "inch" Inch (254//10000)*m false +"The mil, a US customary unit of length defined as 1//1000 inch. +\n\nDimension: [`Unitful.๐‹`](@ref). +\n\nSee Also: [`Unitful.inch`](@ref)." @unit mil "mil" Mil (1//1000)*inch false +"The foot, a US customary unit of length defined as 12 inch. +\n\nDimension: [`Unitful.๐‹`](@ref). +\n\nSee Also: [`Unitful.inch`](@ref)." @unit ft "ft" Foot 12inch false +"The yard, a US customary unit of length defined as 3 ft. +\n\nDimension: [`Unitful.๐‹`](@ref). +\n\nSee Also: [`Unitful.ft`](@ref)." @unit yd "yd" Yard 3ft false +"The mile, a US customary unit of length defined as 1760 yd. +\n\nDimension: [`Unitful.๐‹`](@ref). +\n\nSee Also: [`Unitful.yd`](@ref)." @unit mi "mi" Mile 1760yd false +"The angstrom, a metric unit of length defined as 1//10 nm. +\n\nDimension: [`Unitful.๐‹`](@ref). +\n\nSee Also: [`Unitful.nm`](@ref)." @unit angstrom "โ„ซ" Angstrom (1//10)*nm false # U+00c5 (opt-shift-A on macOS) and U+212b ('\Angstrom' in REPL) look identical: const ร… = โ„ซ = angstrom # Area +"The acre, a US customary unit of area defined as 4840 yd^2. +\n\nDimension: ๐‹^2. +\n\nSee Also: [`Unitful.yd`](@ref)." @unit ac "ac" Acre (316160658//78125)*m^2 false # Temperatures +"The inch, a US customary unit of temperature defined as 5//9 K. +\n\nDimension: [`Unitful.๐šฏ`](@ref). +\n\nSee Also: [`Unitful.K`](@ref)." @unit Ra "Ra" Rankine (5//9)*K false +"Farenheit, a US customary unit of temperature, defined such that 0ยฐF = 459.67Ra. +\n\nDimension: [`Unitful.๐šฏ`](@ref). +\n\nSee also: [`Unitful.Ra`](@ref)." @affineunit ยฐF "ยฐF" (45967//100)Ra # Masses +"The pound-mass, a US customary unit of mass defined as exactly 0.45359237kg. +\n\nDimension: [`Unitful.๐Œ`](@ref). +\n\nSee Also: [`Unitful.kg`](@ref)." @unit lb "lb" Pound 0.45359237kg false # is exact +"The ounce, a US customary unit of mass defined as 1//16 lb. +\n\nDimension: [`Unitful.๐Œ`](@ref). +\n\nSee Also: [`Unitful.lb`](@ref)." @unit oz "oz" Ounce lb//16 false +"The slug, a US customary unit of mass defined as 1lbf*s^2/ft. +\n\nDimension: [`Unitful.๐Œ`](@ref). +\n\nSee Also: [`Unitful.lbf`](@ref), [`Unitful.s`](@ref), [`Unitful.ft`](@ref)." @unit slug "slug" Slug 1lb*ge*s^2/ft false +"The dram, a US customary unit of mass defined as 1//16 oz. +\n\nDimension: [`Unitful.๐Œ`](@ref). +\n\nSee Also: [`Unitful.oz`](@ref)." @unit dr "dr" Dram oz//16 false +"The grain, a US customary unit of mass defined as 32//875 dr. +\n\nDimension: [`Unitful.๐Œ`](@ref). +\n\nSee Also: [`Unitful.dr`](@ref)." @unit gr "gr" Grain (32//875)*dr false # Force +"The pound-force, a US customary unit of force defined as 1lb*ge. +\n\nDimension: ๐‹ ๐Œ ๐“^-2. +\n\nSee Also: [`Unitful.lb`](@ref), [`Unitful.ge`](@ref)." @unit lbf "lbf" PoundsForce 1lb*ge false # Energy # Use ISO 31-4 for BTU definition +"The calorie, a unit of energy defined as exactly 4.184J. +\n\nDimension: ๐‹^2 ๐Œ ๐“^-2. +\n\nSee Also: [`Unitful.J`](@ref)." @unit cal "cal" Calorie 4.184J true +"The calorie, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06J. +\n\nDimension: ๐‹^2 ๐Œ ๐“^-2. +\n\nSee Also: [`Unitful.J`](@ref)." @unit btu "btu" BritishThermalUnit 1055.06J false # Pressure +"Pounds per square inch, a US customary unit of pressure defined as 1lbf/inch^2. +\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\n\nSee Also: [`Unitful.lbf`](@ref), [`Unitful.inch`](@ref)." @unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false ######### From 883d4c6e1855a199d0f2d404e15db96711a733db Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Thu, 7 Oct 2021 09:40:45 -0600 Subject: [PATCH 07/43] Update src/pkgdefaults.jl Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/pkgdefaults.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index ab6690a3..72a89e03 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -14,7 +14,7 @@ @dimension ๐šฏ "๐šฏ" Temperature # This one is \bfTheta "A dimension representing luminosity." @dimension ๐‰ "๐‰" Luminosity -"A dimension representing amounts." +"A dimension representing amount of substance." @dimension ๐ "๐" Amount const RelativeScaleTemperature = Quantity{T, ๐šฏ, <:AffineUnits} where T const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T From ef56ba9b3e8eb00a4a66e79ec3b41d4bff38c07b Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Thu, 7 Oct 2021 09:41:20 -0600 Subject: [PATCH 08/43] Update src/pkgdefaults.jl Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/pkgdefaults.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 72a89e03..1abb5a00 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -8,7 +8,7 @@ @dimension ๐Œ "๐Œ" Mass "A dimension representing time." @dimension ๐“ "๐“" Time -"A dimension representing current." +"A dimension representing electric current." @dimension ๐ˆ "๐ˆ" Current "A dimension representing temperature." @dimension ๐šฏ "๐šฏ" Temperature # This one is \bfTheta From 29199d7d8310a1d4c8d3168544fd8a6723bff983 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Thu, 7 Oct 2021 09:41:31 -0600 Subject: [PATCH 09/43] Update src/pkgdefaults.jl Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/pkgdefaults.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 1abb5a00..c6a011f9 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -12,7 +12,7 @@ @dimension ๐ˆ "๐ˆ" Current "A dimension representing temperature." @dimension ๐šฏ "๐šฏ" Temperature # This one is \bfTheta -"A dimension representing luminosity." +"A dimension representing luminous intensity." @dimension ๐‰ "๐‰" Luminosity "A dimension representing amount of substance." @dimension ๐ "๐" Amount From a3fb3ca0cb88c48f61ec7def57d28029a4dfe04c Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Thu, 7 Oct 2021 09:41:39 -0600 Subject: [PATCH 10/43] Update src/pkgdefaults.jl Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/pkgdefaults.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index c6a011f9..64b45a76 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -10,7 +10,7 @@ @dimension ๐“ "๐“" Time "A dimension representing electric current." @dimension ๐ˆ "๐ˆ" Current -"A dimension representing temperature." +"A dimension representing thermodynamic temperature." @dimension ๐šฏ "๐šฏ" Temperature # This one is \bfTheta "A dimension representing luminous intensity." @dimension ๐‰ "๐‰" Luminosity From e4989dd90c024b9a3d724110ecdc3382da89e95e Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Thu, 7 Oct 2021 09:47:26 -0600 Subject: [PATCH 11/43] Apply suggestions from code review Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/pkgdefaults.jl | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 64b45a76..59d6f5f4 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -60,24 +60,24 @@ const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T # Define base units. This is not to imply g is the base SI unit instead of kg. # See the documentation for further details. # #key: Symbol Display Name Dimension Prefixes? -"The meter, the base SI unit of length. +"The meter, the SI base unit of length. \n\nDimension: [`Unitful.๐‹`](@ref)." @refunit m "m" Meter ๐‹ true -"The second, the base SI unit of time. +"The second, the SI base unit of time. \n\nDimension: [`Unitful.๐“`](@ref)." @refunit s "s" Second ๐“ true -"The ampere, the base SI unit of current. +"The ampere, the SI base unit of electric current. \n\nDimension: [`Unitful.๐ˆ`](@ref)." @refunit A "A" Ampere ๐ˆ true -"The kelvin, the base SI unit of temperature. +"The kelvin, the SI base unit of thermodynamic temperature. \n\nDimension: [`Unitful.๐šฏ`](@ref)." @refunit K "K" Kelvin ๐šฏ true -"The candela, the base SI unit of luminosity. +"The candela, the SI base unit of luminous intensity. \n\nDimension: [`Unitful.๐‰`](@ref)." @refunit cd "cd" Candela ๐‰ true # the docs for all gram-based units are defined later, to ensure kg is the base unit. @refunit g "g" Gram ๐Œ true -"The mol, the base SI unit for amounts of a substance. +"The mole, the SI base unit for amount of substance. \n\nDimension: [`Unitful.๐`](@ref)." @refunit mol "mol" Mole ๐ true @@ -171,14 +171,14 @@ rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r)) \n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit Gy "Gy" Gray 1J/kg true "The sievert, an SI unit of the biological effect of an ionizing radiation dose. -Defined as the health effect of 1Sv of radiation, scaled based on a quality factor. +Defined as the health effect of 1Gy of radiation, scaled by a quality factor. \n\nDimension: ๐‹^2 ๐“^-2. -\n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." +\n\nSee also: [`Unitful.Gy`](@ref)." @unit Sv "Sv" Sievert 1J/kg true "The katal, an SI unit of catalytic activity, defined as 1mol of catalyzed substrate per s. \n\nDimension: ๐ ๐“^-1. -\n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." +\n\nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." @unit kat "kat" Katal 1mol/s true "Percent, a unit meaning parts per hundred." @unit percent "%" Percent 1//100 false @@ -188,7 +188,7 @@ substrate per s. @unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false # Temperature -"Celcius, an SI unit of temperature, defined such that 0ยฐC = 273.15K. +"The degree Celsius, an SI unit of temperature, defined such that 0ยฐC = 273.15K. \n\nDimension: [`Unitful.๐šฏ`](@ref). \n\nSee also: [`Unitful.K`](@ref)." @affineunit ยฐC "ยฐC" (27315//100)K @@ -206,7 +206,7 @@ substrate per s. \n\nDimension: [`Unitful.๐“`](@ref). \n\nSee Also: [`Unitful.hr`](@ref)." @unit d "d" Day 86400s false -"The week, a unit of time, defined as 70d. +"The week, a unit of time, defined as 7d. \n\nDimension: [`Unitful.๐“`](@ref). \n\nSee Also: [`Unitful.d`](@ref)." @unit wk "wk" Week 604800s false @@ -240,8 +240,8 @@ const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, ๐‹^2}(2, 1//1),), ๐‹^2}() # Volume # `l` is also an acceptable symbol for liters -"The liter, a metric unit of volume, defined as 1000cm^2. -\n\nDimension: ๐‹^2. +"The liter, a metric unit of volume, defined as 1000cm^3. +\n\nDimension: ๐‹^3. \n\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, @@ -272,7 +272,7 @@ const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... @unit eV "eV" eV q*V true # For convenience -"A unit for convinience in angular frequency, equal to 2ฯ€ Hz. +"A unit for convenience in angular frequency, equal to 2ฯ€ Hz. \n\nDimension: ๐“^-1. \n\nSee also: [`Unitful.Hz`](@ref)." @unit Hz2ฯ€ "Hz2ฯ€" AngHertz 2ฯ€/s true @@ -378,7 +378,7 @@ const ฯƒ = ฯ€^2*k^4/(60*ฤง^3*c^2) # Stefan-Boltzmann constant \n\nDimension: ๐‹^-1. \n\nSee also: [`Unitful.m`](@ref)." const Rโˆž = 10_973_731.568_160/m # (21) Rydberg constant -"The unifided atomic mass unit, or dalton, a unit of mass defined as 1//12 the +"The unified atomic mass unit, or dalton, a unit of mass defined as 1//12 the mass of an unbound neutral atom of carbon-12. It is defined here to 12 significant figures. \n\nDimension: [`Unitful.๐Œ`](@ref). @@ -420,7 +420,7 @@ earth, a unit of acceleration, defined by standard to be exactly 9.80665 m/s^2. @unit St "St" Stokes 1cm^2/s true "The gauss, a CGS unit of magnetic B-field strength, defined as 1Mx/cm^2. \n\nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. -\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.mx`](@ref)" +\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.Mx`](@ref)" @unit Gauss "Gauss" Gauss (1//10_000)*T true "The oersted, a CGS unit of magnetic H-field strength, defined as (1_000/4ฯ€)A/m. \n\nDimension: ๐ˆ ๐‹^-1. @@ -471,11 +471,11 @@ const ร… = โ„ซ = angstrom @unit ac "ac" Acre (316160658//78125)*m^2 false # Temperatures -"The inch, a US customary unit of temperature defined as 5//9 K. +"The rankine, a US customary unit of temperature defined as 5//9 K. \n\nDimension: [`Unitful.๐šฏ`](@ref). \n\nSee Also: [`Unitful.K`](@ref)." @unit Ra "Ra" Rankine (5//9)*K false -"Farenheit, a US customary unit of temperature, defined such that 0ยฐF = 459.67Ra. +"The degree Fahrenheit, a US customary unit of temperature, defined such that 0ยฐF = 459.67Ra. \n\nDimension: [`Unitful.๐šฏ`](@ref). \n\nSee also: [`Unitful.Ra`](@ref)." @affineunit ยฐF "ยฐF" (45967//100)Ra @@ -514,7 +514,7 @@ const ร… = โ„ซ = angstrom \n\nDimension: ๐‹^2 ๐Œ ๐“^-2. \n\nSee Also: [`Unitful.J`](@ref)." @unit cal "cal" Calorie 4.184J true -"The calorie, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06J. +"The British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06J. \n\nDimension: ๐‹^2 ๐Œ ๐“^-2. \n\nSee Also: [`Unitful.J`](@ref)." @unit btu "btu" BritishThermalUnit 1055.06J false @@ -610,7 +610,7 @@ Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do run = quote @doc $docstring $sym end eval(run) end - @doc "The kilogram, base SI unit of mass. + @doc "The kilogram, the SI base unit of mass. Note that `kg`, not `g`, is the base unit. \n\nDimension: [`Unitful.๐Œ`](@ref)." kg end From ae360f6e95900da27a163a294759b905237920d5 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 9 Oct 2021 14:01:02 -0600 Subject: [PATCH 12/43] Apply suggestions from code review Added descriptions of why certain alternate symbols are used (q for electron charge, minute for minutes) Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/pkgdefaults.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 59d6f5f4..3a10d2b1 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -194,7 +194,8 @@ substrate per s. @affineunit ยฐC "ยฐC" (27315//100)K # Common units of time -"The minute, a unit of time defined as 60s. +"The minute, a unit of time defined as 60s. The full name `minute` is used instead of the symbol `min` +to avoid confusion with the Julia function `min`. \n\nDimension: [`Unitful.๐“`](@ref). \n\nSee Also: [`Unitful.s`](@ref)." @unit minute "minute" Minute 60s false @@ -262,7 +263,8 @@ solute per L of solution. # Energy "A quantity equal to the elementary charge, the charge of a single electron, -with a value of exactly 1.602176634 e-19 C. +with a value of exactly 1.602176634 e-19 C. The letter `q` is used instead of `e` to avoid +confusion with Euler's number. \n\nDimension: ๐ˆ ๐“. \n\nSee Also: [`Unitful.C`](@ref)." const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... From b6168a1a4e0f38d329123cd6e19717347b3c259d Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 9 Oct 2021 16:37:10 -0500 Subject: [PATCH 13/43] Remove excess newlines; add names to docstrings --- src/pkgdefaults.jl | 679 ++++++++++++++++++++++++++------------------- src/user.jl | 2 +- 2 files changed, 394 insertions(+), 287 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 3a10d2b1..d8a6b645 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -2,19 +2,26 @@ # The dimension symbols are generated by tab completion: \bfL is ๐‹, etc. # At the expense of easy typing, this gives a visual cue to distinguish # dimensions from units, and also helps prevent common namespace collisions. -"A dimension representing length." +"`Unitful.๐‹` +\nA dimension representing length." @dimension ๐‹ "๐‹" Length -"A dimension representing mass." +"`Unitful.๐Œ` +\nA dimension representing mass." @dimension ๐Œ "๐Œ" Mass -"A dimension representing time." +"`Unitful.๐“` +\nA dimension representing time." @dimension ๐“ "๐“" Time -"A dimension representing electric current." +"`Unitful.๐ˆ` +\nA dimension representing electric current." @dimension ๐ˆ "๐ˆ" Current -"A dimension representing thermodynamic temperature." +"`Unitful.๐šฏ` +\nA dimension representing thermodynamic temperature." @dimension ๐šฏ "๐šฏ" Temperature # This one is \bfTheta -"A dimension representing luminous intensity." +"`Unitful.๐‰` +\nA dimension representing luminous intensity." @dimension ๐‰ "๐‰" Luminosity -"A dimension representing amount of substance." +"`Unitful.๐` +\nA dimension representing amount of substance." @dimension ๐ "๐" Amount const RelativeScaleTemperature = Quantity{T, ๐šฏ, <:AffineUnits} where T const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T @@ -60,33 +67,42 @@ const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T # Define base units. This is not to imply g is the base SI unit instead of kg. # See the documentation for further details. # #key: Symbol Display Name Dimension Prefixes? -"The meter, the SI base unit of length. -\n\nDimension: [`Unitful.๐‹`](@ref)." +"`Unitful.m` +\nThe meter, the SI base unit of length. +\nDimension: [`Unitful.๐‹`](@ref)." @refunit m "m" Meter ๐‹ true -"The second, the SI base unit of time. -\n\nDimension: [`Unitful.๐“`](@ref)." +"`Unitful.s` +\nThe second, the SI base unit of time. +\nDimension: [`Unitful.๐“`](@ref)." @refunit s "s" Second ๐“ true -"The ampere, the SI base unit of electric current. -\n\nDimension: [`Unitful.๐ˆ`](@ref)." +"`Unitful.A` +\nThe ampere, the SI base unit of electric current. +\nDimension: [`Unitful.๐ˆ`](@ref)." @refunit A "A" Ampere ๐ˆ true -"The kelvin, the SI base unit of thermodynamic temperature. -\n\nDimension: [`Unitful.๐šฏ`](@ref)." +"`Unitful.K` +\nThe kelvin, the SI base unit of thermodynamic temperature. +\nDimension: [`Unitful.๐šฏ`](@ref)." @refunit K "K" Kelvin ๐šฏ true -"The candela, the SI base unit of luminous intensity. -\n\nDimension: [`Unitful.๐‰`](@ref)." +"`Unitful.cd` +\nThe candela, the SI base unit of luminous intensity. +\nDimension: [`Unitful.๐‰`](@ref)." @refunit cd "cd" Candela ๐‰ true # the docs for all gram-based units are defined later, to ensure kg is the base unit. @refunit g "g" Gram ๐Œ true -"The mole, the SI base unit for amount of substance. -\n\nDimension: [`Unitful.๐`](@ref)." +"`Unitful.mol` +\nThe mole, the SI base unit for amount of substance. +\nDimension: [`Unitful.๐`](@ref)." @refunit mol "mol" Mole ๐ true # Angles and solid angles -"The steradian, a unit of spherical angle. There are 4ฯ€ sr in a sphere." +"`Unitful.sr` +\nThe steradian, a unit of spherical angle. There are 4ฯ€ sr in a sphere." @unit sr "sr" Steradian 1 true -"The radian, a unit of angle. There are 2ฯ€ rad in a circle." +"`Unitful.rad` +\nThe radian, a unit of angle. There are 2ฯ€ rad in a circle." @unit rad "rad" Radian 1 true -"The degree, a unit of angle. There are 360ยฐ in a circle." +"`Unitful.ยฐ` +\nThe degree, a unit of angle. There are 360ยฐ in a circle." @unit ยฐ "ยฐ" Degree pi/180 false # For numerical accuracy, specific to the degree import Base: sind, cosd, tand, secd, cscd, cotd @@ -102,148 +118,182 @@ deg2rad(d::Quantity{T, NoDims, typeof(ยฐ)}) where {T} = deg2rad(ustrip(ยฐ, d))u" rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r))u"ยฐ" # SI and related units -"The hertz, an SI unit of frequency, defined as 1/s. -\n\nDimension: ๐“^-1. -\n\nSee also: [`Unitful.s`](@ref)." +"`Unitful.Hz` +\nThe hertz, an SI unit of frequency, defined as 1/s. +\nDimension: ๐“^-1. +\nSee also: [`Unitful.s`](@ref)." @unit Hz "Hz" Hertz 1/s true -"The newton, an SI unit of force, defined as 1kg*m/s^2. -\n\nDimension: ๐‹ ๐Œ ๐“^-2. -\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.s`](@ref)." +"`Unitful.N` +\nThe newton, an SI unit of force, defined as 1kg*m/s^2. +\nDimension: ๐‹ ๐Œ ๐“^-2. +\nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit N "N" Newton 1kg*m/s^2 true -"The pascal, an SI unit of pressure, defined as 1N/m^2. -\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. -\n\nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." +"`Unitful.Pa` +\nThe pascal, an SI unit of pressure, defined as 1N/m^2. +\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." @unit Pa "Pa" Pascal 1N/m^2 true -"The joule, an SI unit of energy, defined as 1N*m. -\n\nDimension: ๐‹^2 ๐Œ ๐“^-2. -\n\nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." +"`Unitful.J` +\nThe joule, an SI unit of energy, defined as 1N*m. +\nDimension: ๐‹^2 ๐Œ ๐“^-2. +\nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." @unit J "J" Joule 1N*m true -"The watt, an SI unit of power, defined as 1J/s. -\n\nDimension: ๐‹^2 ๐Œ ๐“^-3. -\n\nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." +"`Unitful.W` +\nThe watt, an SI unit of power, defined as 1J/s. +\nDimension: ๐‹^2 ๐Œ ๐“^-3. +\nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." @unit W "W" Watt 1J/s true -"The coulomb, an SI unit of electric charge, defined as 1A*s. -\n\nDimension: ๐ˆ ๐“. -\n\nSee also: [`Unitful.A`](@ref), [`Unitful.s`](@ref)." +"`Unitful.C` +\nThe coulomb, an SI unit of electric charge, defined as 1A*s. +\nDimension: ๐ˆ ๐“. +\nSee also: [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit C "C" Coulomb 1A*s true -"The volt, an SI unit of electric potential, defined as 1W/A. -\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-3. -\n\nSee also: [`Unitful.W`](@ref), [`Unitful.A`](@ref)" +"`Unitful.V` +\nThe volt, an SI unit of electric potential, defined as 1W/A. +\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-3. +\nSee also: [`Unitful.W`](@ref), [`Unitful.A`](@ref)" @unit V "V" Volt 1W/A true -"The ohm, an SI unit of electrical resistance, defined as 1V/A. -\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. -\n\nSee also: [`Unitful.V`](@ref), [`Unitful.A`](@ref)." +"`Unitful.โ„ฆ` +\nThe ohm, an SI unit of electrical resistance, defined as 1V/A. +\nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. +\nSee also: [`Unitful.V`](@ref), [`Unitful.A`](@ref)." @unit ฮฉ "ฮฉ" Ohm 1V/A true -"The siemens, an SI unit of electrical conductance, defined as 1/ฮฉ. -\n\nDimension: ๐ˆ^2 ๐“^3 ๐‹^-2 ๐Œ^-1. -\n\nSee also: [`Unitful.ฮฉ`](@ref)" +"`Unitful.S` +\nThe siemens, an SI unit of electrical conductance, defined as 1/ฮฉ. +\nDimension: ๐ˆ^2 ๐“^3 ๐‹^-2 ๐Œ^-1. +\nSee also: [`Unitful.ฮฉ`](@ref)" @unit S "S" Siemens 1/ฮฉ true -"The farad, an SI unit of electrical capacitance, defined as 1s^4*A^2/(kg*m^2). -\n\nDimension: ๐ˆ^2 ๐“^4 ๐‹^-2 ๐Œ^-1. -\n\nSee also: [`Unitful.s`](@ref), [`Unitful.A`](@ref), [`Unitful.kg`](@ref), [`Unitful.m`](@ref)." +"`Unitful.F` +\nThe farad, an SI unit of electrical capacitance, defined as 1s^4*A^2/(kg*m^2). +\nDimension: ๐ˆ^2 ๐“^4 ๐‹^-2 ๐Œ^-1. +\nSee also: [`Unitful.s`](@ref), [`Unitful.A`](@ref), [`Unitful.kg`](@ref), [`Unitful.m`](@ref)." @unit F "F" Farad 1s^4*A^2/(kg*m^2) true -"The henry, an SI unit of electrical inductance, defined as 1J/(A^2). -\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-2. -\n\nSee also: [`Unitful.J`](@ref), [`Unitful.A`](@ref)." +"`Unitful.H` +\nThe henry, an SI unit of electrical inductance, defined as 1J/(A^2). +\nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-2. +\nSee also: [`Unitful.J`](@ref), [`Unitful.A`](@ref)." @unit H "H" Henry 1J/(A^2) true -"The tesla, an SI unit of magnetic B-field strength, defined as 1kg/(A*s^2). -\n\nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. -\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." +"`Unitful.T` +\nThe tesla, an SI unit of magnetic B-field strength, defined as 1kg/(A*s^2). +\nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. +\nSee also: [`Unitful.kg`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit T "T" Tesla 1kg/(A*s^2) true -"The weber, an SI unit of magnetic flux, defined as 1kg*m^2/(A*s^2). -\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. -\n\nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." +"`Unitful.Wb` +\nThe weber, an SI unit of magnetic flux, defined as 1kg*m^2/(A*s^2). +\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. +\nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true -"The lumen, an SI unit of luminous flux, defined as 1cd*sr. -\n\nDimension: ๐‰. -\n\nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)." +"`Unitful.lm` +\nThe lumen, an SI unit of luminous flux, defined as 1cd*sr. +\nDimension: ๐‰. +\nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)." @unit lm "lm" Lumen 1cd*sr true -"The lux, an SI unit of illuminance, defined as 1lm/m^2. -\n\nDimension: ๐‰ ๐‹^-2. -\n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." +"`Unitful.lx` +\nThe lux, an SI unit of illuminance, defined as 1lm/m^2. +\nDimension: ๐‰ ๐‹^-2. +\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit lx "lx" Lux 1lm/m^2 true -"The becquerel, an SI unit of radioactivity, defined as 1 nuclear decay per s. -\n\nDimension: ๐“^-1. -\n\nSee also: [`Unitful.s`](@ref)." +"`Unitful.Bq` +\nThe becquerel, an SI unit of radioactivity, defined as 1 nuclear decay per s. +\nDimension: ๐“^-1. +\nSee also: [`Unitful.s`](@ref)." @unit Bq "Bq" Becquerel 1/s true -"The gray, an SI unit of ionizing radiation dose, defined as the absorbtion of 1J per kg of matter. -\n\nDimension: ๐‹^2 ๐“^-2. -\n\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." +"`Unitful.Gy` +\nThe gray, an SI unit of ionizing radiation dose, defined as the absorbtion of 1J per kg of matter. +\nDimension: ๐‹^2 ๐“^-2. +\nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit Gy "Gy" Gray 1J/kg true -"The sievert, an SI unit of the biological effect of an ionizing radiation dose. +"`Unitful.Sv` +\nThe sievert, an SI unit of the biological effect of an ionizing radiation dose. Defined as the health effect of 1Gy of radiation, scaled by a quality factor. -\n\nDimension: ๐‹^2 ๐“^-2. -\n\nSee also: [`Unitful.Gy`](@ref)." +\nDimension: ๐‹^2 ๐“^-2. +\nSee also: [`Unitful.Gy`](@ref)." @unit Sv "Sv" Sievert 1J/kg true -"The katal, an SI unit of catalytic activity, defined as 1mol of catalyzed +"`Unitful.kat` +\nThe katal, an SI unit of catalytic activity, defined as 1mol of catalyzed substrate per s. -\n\nDimension: ๐ ๐“^-1. -\n\nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." +\nDimension: ๐ ๐“^-1. +\nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." @unit kat "kat" Katal 1mol/s true -"Percent, a unit meaning parts per hundred." +"`Unitful.percent` +\nPercent, a unit meaning parts per hundred." @unit percent "%" Percent 1//100 false -"Permille, a unit meaning parts per thousand." +"`Unitful.permille` +\nPermille, a unit meaning parts per thousand." @unit permille "โ€ฐ" Permille 1//1000 false -"Permyriad, a unit meaning parts per ten thousand." +"`Unitful.pertenthousand` +\nPermyriad, a unit meaning parts per ten thousand." @unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false # Temperature -"The degree Celsius, an SI unit of temperature, defined such that 0ยฐC = 273.15K. -\n\nDimension: [`Unitful.๐šฏ`](@ref). -\n\nSee also: [`Unitful.K`](@ref)." +"`Unitful.ยฐC` +\nThe degree Celsius, an SI unit of temperature, defined such that 0ยฐC = 273.15K. +\nDimension: [`Unitful.๐šฏ`](@ref). +\nSee also: [`Unitful.K`](@ref)." @affineunit ยฐC "ยฐC" (27315//100)K # Common units of time -"The minute, a unit of time defined as 60s. The full name `minute` is used instead of the symbol `min` +"`Unitful.minute` +\nThe minute, a unit of time defined as 60s. The full name `minute` is used instead of the symbol `min` to avoid confusion with the Julia function `min`. -\n\nDimension: [`Unitful.๐“`](@ref). -\n\nSee Also: [`Unitful.s`](@ref)." +\nDimension: [`Unitful.๐“`](@ref). +\nSee Also: [`Unitful.s`](@ref)." @unit minute "minute" Minute 60s false -"The hour, a unit of time defined as 60 minutes. -\n\nDimension: [`Unitful.๐“`](@ref). -\n\nSee Also: [`Unitful.minute`](@ref)." +"`Unitful.hr` +\nThe hour, a unit of time defined as 60 minutes. +\nDimension: [`Unitful.๐“`](@ref). +\nSee Also: [`Unitful.minute`](@ref)." @unit hr "hr" Hour 3600s false -"The day, a unit of time defined as 24hr. -\n\nDimension: [`Unitful.๐“`](@ref). -\n\nSee Also: [`Unitful.hr`](@ref)." +"`Unitful.d` +\nThe day, a unit of time defined as 24hr. +\nDimension: [`Unitful.๐“`](@ref). +\nSee Also: [`Unitful.hr`](@ref)." @unit d "d" Day 86400s false -"The week, a unit of time, defined as 7d. -\n\nDimension: [`Unitful.๐“`](@ref). -\n\nSee Also: [`Unitful.d`](@ref)." +"`Unitful.wk` +\nThe week, a unit of time, defined as 7d. +\nDimension: [`Unitful.๐“`](@ref). +\nSee Also: [`Unitful.d`](@ref)." @unit wk "wk" Week 604800s false -"The year, a unit of time, defined as 8766hr. -\n\nDimension: [`Unitful.๐“`](@ref). -\n\nSee Also: [`Unitful.hr`](@ref)." +"`Unitful.yr` +\nThe year, a unit of time, defined as 8766hr. +\nDimension: [`Unitful.๐“`](@ref). +\nSee Also: [`Unitful.hr`](@ref)." @unit yr "yr" Year 31557600s true -"Revolutions per second, a unit of rotational speed, defined as one rotation per s. -\n\nDimension: ๐“^-1. -\n\nSee Also: [`Unitful.s`](@ref)." +"`Unitful.rps` +\nRevolutions per second, a unit of rotational speed, defined as one rotation per s. +\nDimension: ๐“^-1. +\nSee Also: [`Unitful.s`](@ref)." @unit rps "rps" RevolutionsPerSecond 2ฯ€*rad/s false -"Revolutions per minute, a unit of rotational speed, defined as one rotation per minute. -\n\nDimension: ๐“^-1. -\n\nSee Also: [`Unitful.minute`](@ref)." +"`Unitful.rpm` +\nRevolutions per minute, a unit of rotational speed, defined as one rotation per minute. +\nDimension: ๐“^-1. +\nSee Also: [`Unitful.minute`](@ref)." @unit rpm "rpm" RevolutionsPerMinute 2ฯ€*rad/minute false # Area # The hectare is used more frequently than any other power-of-ten of an are. -"The are, a metric unit of area, defined as 100m^2. -\n\nDimension: ๐‹^2. -\n\nSee Also: [`Unitful.m`](@ref)." +"`Unitful.a` +\nThe are, a metric unit of area, defined as 100m^2. +\nDimension: ๐‹^2. +\nSee Also: [`Unitful.m`](@ref)." @unit a "a" Are 100m^2 false -"The hectare, a metric unit of area, defined as 100a. -\n\nDimension: ๐‹^2. -\n\nSee Also: [`Unitful.a`](@ref)." +"`Unitful.ha` +\nThe hectare, a metric unit of area, defined as 100a. +\nDimension: ๐‹^2. +\nSee Also: [`Unitful.a`](@ref)." const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, ๐‹^2}(2, 1//1),), ๐‹^2}() -"The barn, a metric unit of area, defined as 100fm^2. -\n\nDimension: ๐‹^2. -\n\nSee Also: [`Unitful.fm`](@ref)." +"`Unitful.b` +\nThe barn, a metric unit of area, defined as 100fm^2. +\nDimension: ๐‹^2. +\nSee Also: [`Unitful.fm`](@ref)." @unit b "b" Barn 100fm^2 true # Volume # `l` is also an acceptable symbol for liters -"The liter, a metric unit of volume, defined as 1000cm^3. -\n\nDimension: ๐‹^3. -\n\nSee Also: [`Unitful.cm`](@ref)." +"`Unitful.L` +\nThe liter, a metric unit of volume, defined as 1000cm^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) @@ -255,182 +305,219 @@ for p in (:y, :z, :a, :f, :p, :n, :ฮผ, :ยต, :m, :c, :d, end # Molarity -"A unit for measuring molar concentration, a 1 molar solution has 1 mol of +"`Unitful.M` +\nA unit for measuring molar concentration, a 1 molar solution has 1 mol of solute per L of solution. -\n\nDimension: ๐ ๐‹^-3. -\n\nSee Also: [`Unitful.L`](@ref), [`Unitful.mol`](@ref)." +\nDimension: ๐ ๐‹^-3. +\nSee Also: [`Unitful.L`](@ref), [`Unitful.mol`](@ref)." @unit M "M" Molar 1mol/L true # Energy -"A quantity equal to the elementary charge, the charge of a single electron, +"`Unitful.q` +\nA quantity equal to the elementary charge, the charge of a single electron, with a value of exactly 1.602176634 e-19 C. The letter `q` is used instead of `e` to avoid confusion with Euler's number. -\n\nDimension: ๐ˆ ๐“. -\n\nSee Also: [`Unitful.C`](@ref)." +\nDimension: ๐ˆ ๐“. +\nSee Also: [`Unitful.C`](@ref)." const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... -"The electron-volt, a unit of energy, defined as q*V. -\n\nDimension: ๐‹^2 ๐Œ ๐“^-2. -\n\nSee also: [`Unitful.q`](@ref), [`Unitful.V`](@ref)." +"`Unitful.eV` +\nThe electron-volt, a unit of energy, defined as q*V. +\nDimension: ๐‹^2 ๐Œ ๐“^-2. +\nSee also: [`Unitful.q`](@ref), [`Unitful.V`](@ref)." @unit eV "eV" eV q*V true # For convenience -"A unit for convenience in angular frequency, equal to 2ฯ€ Hz. -\n\nDimension: ๐“^-1. -\n\nSee also: [`Unitful.Hz`](@ref)." +"`Unitful.Hz2ฯ€` +\nA unit for convenience in angular frequency, equal to 2ฯ€ Hz. +\nDimension: ๐“^-1. +\nSee also: [`Unitful.Hz`](@ref)." @unit Hz2ฯ€ "Hz2ฯ€" AngHertz 2ฯ€/s true -"The bar, a metric unit of pressure, defined as 100 kPa. -\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. -\n\nSee also: [`Unitful.kPa`](@ref)." +"`Unitful.bar` +\nThe bar, a metric unit of pressure, defined as 100 kPa. +\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\nSee also: [`Unitful.kPa`](@ref)." @unit bar "bar" Bar 100000Pa true -"The standard atmosphere, a unit of pressure, defined as 101,325 Pa. -\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. -\n\nSee also: [`Unitful.Pa`](@ref)." +"`Unitful.atm` +\nThe standard atmosphere, a unit of pressure, defined as 101,325 Pa. +\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\nSee also: [`Unitful.Pa`](@ref)." @unit atm "atm" Atmosphere 101325Pa false -"The torr, a unit of pressure, defined as 1//760 atm. -\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. -\n\nSee also: [`Unitful.atm`](@ref)." +"`Unitful.Torr` +\nThe torr, a unit of pressure, defined as 1//760 atm. +\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\nSee also: [`Unitful.atm`](@ref)." @unit Torr "Torr" Torr 101325Pa//760 true # Constants (2018 CODATA values) (uncertainties in final digits) -"A quantity representing the speed of light in a vacuum, defined as exactly +"`Unitful.c0` +\nA quantity representing the speed of light in a vacuum, defined as exactly 299,792,458 m/s. -\n\nDimension: ๐‹ ๐“^-1. -\n\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." +\nDimension: ๐‹ ๐“^-1. +\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const c0 = 299_792_458*m/s # exact -"The speed of light in a vacuum, a unit of speed, defined as exactly +"`Unitful.c` +\nThe speed of light in a vacuum, a unit of speed, defined as exactly 299,792,458 m/s. -\n\nDimension: ๐‹ ๐“^-1. -\n\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." +\nDimension: ๐‹ ๐“^-1. +\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit c "c" SpeedOfLight 1c0 false -"A quantity representing the vacuum permeability constant, defined as 4ฯ€ * 1e-7 H/m. -\n\nDimension: ๐‹ ๐Œ ๐ˆ^-2 ๐“^-2. -\n\nSee also: [`Unitful.H`](@ref), [`Unitful.m`](@ref)." +"`Unitful.ฮผ0` +\nA quantity representing the vacuum permeability constant, defined as 4ฯ€ * 1e-7 H/m. +\nDimension: ๐‹ ๐Œ ๐ˆ^-2 ๐“^-2. +\nSee also: [`Unitful.H`](@ref), [`Unitful.m`](@ref)." const ฮผ0 = 4ฯ€*(1//10)^7*H/m # exact (but gets promoted to Float64...) const ยต0 = ฮผ0 # magnetic constant -"A quantity representing the vacuum permittivity constant, defined as 1/(ฮผ0*c^2). -\n\nDimension: ๐ˆ^2 ๐“^4 ๐‹^-3 ๐Œ^-1. -\n\nSee also: [`Unitful.ฮผ0`](@ref), [`Unitful.c`](@ref)." +"`Unitful.ฮต0` +\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 const ฯต0 = ษ›0 # test of issue 79. -"A quantity representing the impedance of free space, a constant defined as ฮผ0*c. -\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. -\n\nSee also: [`Unitful.ฮผ0`](@ref), [`Unitful.c`](@ref)." +"`Unitful.Z0` +\nA quantity representing the impedance of free space, a constant defined as ฮผ0*c. +\nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. +\nSee also: [`Unitful.ฮผ0`](@ref), [`Unitful.c`](@ref)." const Z0 = ฮผ0*c # exact, impedance of free space -"A quantity representing the universal gravitational constant. -\n\nDimension: ๐‹^3 ๐Œ^-1 ๐“^-2. -\n\nSee also: [`Unitful.m`](@ref), [`Unitful.kg`](@ref), [`Unitful.s`](@ref)." +"`Unitful.G` +\nA quantity representing the universal gravitational constant. +\nDimension: ๐‹^3 ๐Œ^-1 ๐“^-2. +\nSee also: [`Unitful.m`](@ref), [`Unitful.kg`](@ref), [`Unitful.s`](@ref)." const G = 6.674_30e-11*m^3/kg/s^2 # (15) gravitational constant -"A quantity representing the nominal acceleration due to gravity in a vacuum +"`Unitful.gn` +\nA quantity representing the nominal acceleration due to gravity in a vacuum near the surface of the earth, defined by standard to be exactly 9.80665 m/s^2. -\n\nDimension: ๐‹ ๐“^-2. -\n\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." +\nDimension: ๐‹ ๐“^-2. +\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const gn = 9.80665*m/s^2 # exact, standard acceleration of gravity -"A quantity representing Planck's constant, defined as exactly +"`Unitful.h` +\nA quantity representing Planck's constant, defined as exactly 6.62607015 e-34 J*s. -\n\nDimension: ๐‹^2 ๐Œ ๐“^-1. -\n\nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." +\nDimension: ๐‹^2 ๐Œ ๐“^-1. +\nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." const h = 6.626_070_15e-34*J*s # exact, Planck constant -"A quantity representing the reduced Planck constant, defined as h/(2ฯ€). -\n\nDimension: ๐‹^2 ๐Œ ๐“^-1. -\n\nSee also: [`Unitful.h`](@ref)." +"`Unitful.ฤง` +\nA quantity representing the reduced Planck constant, defined as h/(2ฯ€). +\nDimension: ๐‹^2 ๐Œ ๐“^-1. +\nSee also: [`Unitful.h`](@ref)." const ฤง = h/2ฯ€ # hbar -"A quantity representing the superconducting magnetic flux quantum, defined as +"`Unitful.ฮฆ0` +\nA quantity representing the superconducting magnetic flux quantum, defined as h/(2q). -\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. -\n\nSee also: [`Unitful.h`](@ref), [`Unitful.q`](@ref)." +\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. +\nSee also: [`Unitful.h`](@ref), [`Unitful.q`](@ref)." const ฮฆ0 = h/(2q) # Superconducting magnetic flux quantum -"A quantity representing the rest mass of an electron, given to 11 significant figures. -\n\nDimension: ๐Œ. -\n\nSee also: [`Unitful.kg`](@ref)." +"`Unitful.me` +\nA quantity representing the rest mass of an electron, given to 11 significant figures. +\nDimension: ๐Œ. +\nSee also: [`Unitful.kg`](@ref)." const me = 9.109_383_7015e-31*kg # (28) electron rest mass -"A quantity representing the rest mass of a neutron, given to 12 significant figures. -\n\nDimension: ๐Œ. -\n\nSee also: [`Unitful.kg`](@ref)." +"`Unitful.mn` +\nA quantity representing the rest mass of a neutron, given to 12 significant figures. +\nDimension: ๐Œ. +\nSee also: [`Unitful.kg`](@ref)." const mn = 1.674_927_498_04e-27*kg # (95) neutron rest mass -"A quantity representing the rest mass of a proton, given to 12 significant figures. -\n\nDimension: ๐Œ. -\n\nSee also: [`Unitful.kg`](@ref)." +"`Unitful.mp` +\nA quantity representing the rest mass of a proton, given to 12 significant figures. +\nDimension: ๐Œ. +\nSee also: [`Unitful.kg`](@ref)." const mp = 1.672_621_923_69e-27*kg # (51) proton rest mass -"A quantity representing the Bohr magneton, given to 11 significant figures. -\n\nDimension: ๐ˆ ๐‹^2. -\n\nSee also: [`Unitful.q`](@ref), [`Unitful.ฤง`](@ref), [`Unitful.me`](@ref)." +"`Unitful.ฮผB` +\nA quantity representing the Bohr magneton, given to 11 significant figures. +\nDimension: ๐ˆ ๐‹^2. +\nSee also: [`Unitful.q`](@ref), [`Unitful.ฤง`](@ref), [`Unitful.me`](@ref)." const ฮผB = q*ฤง/(2*me) # Bohr magneton const ยตB = ฮผB -"A quantity representing Avogadro's constant, defined as exactly +"`Unitful.Na` +\nA quantity representing Avogadro's constant, defined as exactly 6.02214076 e23 / mol. -\n\nDimension: ๐^-1. -\n\nSee also: [`Unitful.mol`](@ref)." +\nDimension: ๐^-1. +\nSee also: [`Unitful.mol`](@ref)." const Na = 6.022_140_76e23/mol # exact, Avogadro constant -"A quantity representing the Boltzmann constant, defined as exactly +"`Unitful.k` +\nA quantity representing the Boltzmann constant, defined as exactly 1.380649 e-23 J/K. -\n\nDimension: ๐‹^2 ๐Œ ๐šฏ^-1 ๐“^-2. -\n\nSee also: [`Unitful.J`](@ref), [`Unitful.K`](@ref)." +\nDimension: ๐‹^2 ๐Œ ๐šฏ^-1 ๐“^-2. +\nSee also: [`Unitful.J`](@ref), [`Unitful.K`](@ref)." const k = 1.380_649e-23*(J/K) # exact, Boltzmann constant -"A quantity representing the molar gas constant, defined as +"`Unitful.R` +\nA quantity representing the molar gas constant, defined as Na*k. -\n\nDimension: ๐‹^2 ๐Œ ๐^-1 ๐šฏ^-1 ๐“^-2. -\n\nSee also: [`Unitful.Na`](@ref), [`Unitful.k`](@ref)." +\nDimension: ๐‹^2 ๐Œ ๐^-1 ๐šฏ^-1 ๐“^-2. +\nSee also: [`Unitful.Na`](@ref), [`Unitful.k`](@ref)." const R = Na*k # molar gas constant -"A quantity representing the Stefan-Boltzmann constant, defined as +"`Unitful.ฯƒ` +\nA quantity representing the Stefan-Boltzmann constant, defined as ฯ€^2*k^4/(60*ฤง^3*c^2). -\n\nDimension: ๐Œ ๐šฏ^-4 ๐“^-3. -\n\nSee also: [`Unitful.k`](@ref), [`Unitful.ฤง`](@ref), [`Unitful.c`](@ref)." +\nDimension: ๐Œ ๐šฏ^-4 ๐“^-3. +\nSee also: [`Unitful.k`](@ref), [`Unitful.ฤง`](@ref), [`Unitful.c`](@ref)." const ฯƒ = ฯ€^2*k^4/(60*ฤง^3*c^2) # Stefan-Boltzmann constant -"A quantity representing the Bohr magneton, given to 14 significant figures. -\n\nDimension: ๐‹^-1. -\n\nSee also: [`Unitful.m`](@ref)." +"`Unitful.Rโˆž` +\nA quantity representing the Bohr magneton, given to 14 significant figures. +\nDimension: ๐‹^-1. +\nSee also: [`Unitful.m`](@ref)." const Rโˆž = 10_973_731.568_160/m # (21) Rydberg constant -"The unified atomic mass unit, or dalton, a unit of mass defined as 1//12 the +"`Unitful.u` +\nThe unified atomic mass unit, or dalton, a unit of mass defined as 1//12 the mass of an unbound neutral atom of carbon-12. It is defined here to 12 significant figures. -\n\nDimension: [`Unitful.๐Œ`](@ref). -\n\nSee Also: [`Unitful.kg`](@ref)." +\nDimension: [`Unitful.๐Œ`](@ref). +\nSee Also: [`Unitful.kg`](@ref)." @unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false # (50) # Acceleration -"The nominal acceleration due to gravity in a vacuum near the surface of the +"`Unitful.ge` +\nThe nominal acceleration due to gravity in a vacuum near the surface of the earth, a unit of acceleration, defined by standard to be exactly 9.80665 m/s^2. -\n\nDimension: ๐‹ ๐“^-2. -\n\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." +\nDimension: ๐‹ ๐“^-2. +\nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit ge "ge" EarthGravity gn false # CGS units -"The gal, a CGS unit of acceleration, defined as 1cm/s^2. -\n\nDimension: ๐‹ ๐“^-2. -\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)." +"`Unitful.Gal` +\nThe gal, a CGS unit of acceleration, defined as 1cm/s^2. +\nDimension: ๐‹ ๐“^-2. +\nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)." @unit Gal "Gal" Gal 1cm/s^2 true -"The dyne, a CGS unit of force, defined as 1g*cm/s^2. -\n\nDimension: ๐‹ ๐Œ ๐“^-2. -\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref), [`Unitful.g`](@ref)." +"`Unitful.dyn` +\nThe dyne, a CGS unit of force, defined as 1g*cm/s^2. +\nDimension: ๐‹ ๐Œ ๐“^-2. +\nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref), [`Unitful.g`](@ref)." @unit dyn "dyn" Dyne 1g*cm/s^2 true -"The erg, a CGS unit of energy, defined as 1dyn*cm. -\n\nDimension: ๐‹^2 ๐Œ ๐“^-2. -\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" +"`Unitful.erg` +\nThe erg, a CGS unit of energy, defined as 1dyn*cm. +\nDimension: ๐‹^2 ๐Œ ๐“^-2. +\nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" @unit erg "erg" Erg 1g*cm^2/s^2 true -"The barye, a CGS unit of pressure, defined as 1dyn/cm^2. -\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. -\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" +"`Unitful.Ba` +\nThe barye, a CGS unit of pressure, defined as 1dyn/cm^2. +\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" @unit Ba "Ba" Barye 1g/cm/s^2 true -"The poise, a CGS unit of dynamic viscosity, defined as 1dyn*s/cm^2. -\n\nDimension: ๐Œ ๐‹^-1 ๐“^-1. -\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref), [`Unitful.s`](@ref)" +"`Unitful.P` +\nThe poise, a CGS unit of dynamic viscosity, defined as 1dyn*s/cm^2. +\nDimension: ๐Œ ๐‹^-1 ๐“^-1. +\nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref), [`Unitful.s`](@ref)" @unit P "P" Poise 1g/cm/s true -"The stokes, a CGS unit of kinematic viscosity, defined as 1cm^2/s. -\n\nDimension: ๐Œ^2 ๐“^-1. -\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)" +"`Unitful.St` +\nThe stokes, a CGS unit of kinematic viscosity, defined as 1cm^2/s. +\nDimension: ๐Œ^2 ๐“^-1. +\nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)" @unit St "St" Stokes 1cm^2/s true -"The gauss, a CGS unit of magnetic B-field strength, defined as 1Mx/cm^2. -\n\nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. -\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.Mx`](@ref)" +"`Unitful.Gauss` +\nThe gauss, a CGS unit of magnetic B-field strength, defined as 1Mx/cm^2. +\nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. +\nSee also: [`Unitful.cm`](@ref), [`Unitful.Mx`](@ref)" @unit Gauss "Gauss" Gauss (1//10_000)*T true -"The oersted, a CGS unit of magnetic H-field strength, defined as (1_000/4ฯ€)A/m. -\n\nDimension: ๐ˆ ๐‹^-1. -\n\nSee also: [`Unitful.A`](@ref), [`Unitful.m`](@ref)" +"`Unitful.Oe` +\nThe oersted, a CGS unit of magnetic H-field strength, defined as (1_000/4ฯ€)A/m. +\nDimension: ๐ˆ ๐‹^-1. +\nSee also: [`Unitful.A`](@ref), [`Unitful.m`](@ref)" @unit Oe "Oe" Oersted (1_000/4ฯ€)*A/m true -"The maxwell, a CGS unit of magnetic flux, defined as 1Gauss*cm^2. -\n\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. -\n\nSee also: [`Unitful.cm`](@ref), [`Unitful.Gauss`](@ref)" +"`Unitful.Mx` +\nThe maxwell, a CGS unit of magnetic flux, defined as 1Gauss*cm^2. +\nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. +\nSee also: [`Unitful.cm`](@ref), [`Unitful.Gauss`](@ref)" @unit Mx "Mx" Maxwell (1//100_000_000)*Wb true @@ -439,92 +526,110 @@ earth, a unit of acceleration, defined by standard to be exactly 9.80665 m/s^2. # Length #key: Symbol Display Name Equivalent to 10^n prefixes? -"The inch, a US customary unit of length defined as 254//10000 m. -\n\nDimension: [`Unitful.๐‹`](@ref). -\n\nSee Also: [`Unitful.m`](@ref)." +"`Unitful.inch` +\nThe inch, a US customary unit of length defined as 254//10000 m. +\nDimension: [`Unitful.๐‹`](@ref). +\nSee Also: [`Unitful.m`](@ref)." @unit inch "inch" Inch (254//10000)*m false -"The mil, a US customary unit of length defined as 1//1000 inch. -\n\nDimension: [`Unitful.๐‹`](@ref). -\n\nSee Also: [`Unitful.inch`](@ref)." +"`Unitful.mil` +\nThe mil, a US customary unit of length defined as 1//1000 inch. +\nDimension: [`Unitful.๐‹`](@ref). +\nSee Also: [`Unitful.inch`](@ref)." @unit mil "mil" Mil (1//1000)*inch false -"The foot, a US customary unit of length defined as 12 inch. -\n\nDimension: [`Unitful.๐‹`](@ref). -\n\nSee Also: [`Unitful.inch`](@ref)." +"`Unitful.ft` +\nThe foot, a US customary unit of length defined as 12 inch. +\nDimension: [`Unitful.๐‹`](@ref). +\nSee Also: [`Unitful.inch`](@ref)." @unit ft "ft" Foot 12inch false -"The yard, a US customary unit of length defined as 3 ft. -\n\nDimension: [`Unitful.๐‹`](@ref). -\n\nSee Also: [`Unitful.ft`](@ref)." +"`Unitful.yd` +\nThe yard, a US customary unit of length defined as 3 ft. +\nDimension: [`Unitful.๐‹`](@ref). +\nSee Also: [`Unitful.ft`](@ref)." @unit yd "yd" Yard 3ft false -"The mile, a US customary unit of length defined as 1760 yd. -\n\nDimension: [`Unitful.๐‹`](@ref). -\n\nSee Also: [`Unitful.yd`](@ref)." +"`Unitful.mi` +\nThe mile, a US customary unit of length defined as 1760 yd. +\nDimension: [`Unitful.๐‹`](@ref). +\nSee Also: [`Unitful.yd`](@ref)." @unit mi "mi" Mile 1760yd false -"The angstrom, a metric unit of length defined as 1//10 nm. -\n\nDimension: [`Unitful.๐‹`](@ref). -\n\nSee Also: [`Unitful.nm`](@ref)." +"`Unitful.โ„ซ` +\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 # U+00c5 (opt-shift-A on macOS) and U+212b ('\Angstrom' in REPL) look identical: const ร… = โ„ซ = angstrom # Area -"The acre, a US customary unit of area defined as 4840 yd^2. -\n\nDimension: ๐‹^2. -\n\nSee Also: [`Unitful.yd`](@ref)." +"`Unitful.ac` +\nThe acre, a US customary unit of area defined as 4840 yd^2. +\nDimension: ๐‹^2. +\nSee Also: [`Unitful.yd`](@ref)." @unit ac "ac" Acre (316160658//78125)*m^2 false # Temperatures -"The rankine, a US customary unit of temperature defined as 5//9 K. -\n\nDimension: [`Unitful.๐šฏ`](@ref). -\n\nSee Also: [`Unitful.K`](@ref)." +"`Unitful.Ra` +\nThe rankine, a US customary unit of temperature defined as 5//9 K. +\nDimension: [`Unitful.๐šฏ`](@ref). +\nSee Also: [`Unitful.K`](@ref)." @unit Ra "Ra" Rankine (5//9)*K false -"The degree Fahrenheit, a US customary unit of temperature, defined such that 0ยฐF = 459.67Ra. -\n\nDimension: [`Unitful.๐šฏ`](@ref). -\n\nSee also: [`Unitful.Ra`](@ref)." +"`Unitful.ยฐF` +\nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0ยฐF = 459.67Ra. +\nDimension: [`Unitful.๐šฏ`](@ref). +\nSee also: [`Unitful.Ra`](@ref)." @affineunit ยฐF "ยฐF" (45967//100)Ra # Masses -"The pound-mass, a US customary unit of mass defined as exactly 0.45359237kg. -\n\nDimension: [`Unitful.๐Œ`](@ref). -\n\nSee Also: [`Unitful.kg`](@ref)." +"`Unitful.lb` +\nThe pound-mass, a US customary unit of mass defined as exactly 0.45359237kg. +\nDimension: [`Unitful.๐Œ`](@ref). +\nSee Also: [`Unitful.kg`](@ref)." @unit lb "lb" Pound 0.45359237kg false # is exact -"The ounce, a US customary unit of mass defined as 1//16 lb. -\n\nDimension: [`Unitful.๐Œ`](@ref). -\n\nSee Also: [`Unitful.lb`](@ref)." +"`Unitful.oz` +\nThe ounce, a US customary unit of mass defined as 1//16 lb. +\nDimension: [`Unitful.๐Œ`](@ref). +\nSee Also: [`Unitful.lb`](@ref)." @unit oz "oz" Ounce lb//16 false -"The slug, a US customary unit of mass defined as 1lbf*s^2/ft. -\n\nDimension: [`Unitful.๐Œ`](@ref). -\n\nSee Also: [`Unitful.lbf`](@ref), [`Unitful.s`](@ref), [`Unitful.ft`](@ref)." +"`Unitful.slug` +\nThe slug, a US customary unit of mass defined as 1lbf*s^2/ft. +\nDimension: [`Unitful.๐Œ`](@ref). +\nSee Also: [`Unitful.lbf`](@ref), [`Unitful.s`](@ref), [`Unitful.ft`](@ref)." @unit slug "slug" Slug 1lb*ge*s^2/ft false -"The dram, a US customary unit of mass defined as 1//16 oz. -\n\nDimension: [`Unitful.๐Œ`](@ref). -\n\nSee Also: [`Unitful.oz`](@ref)." +"`Unitful.dr` +\nThe dram, a US customary unit of mass defined as 1//16 oz. +\nDimension: [`Unitful.๐Œ`](@ref). +\nSee Also: [`Unitful.oz`](@ref)." @unit dr "dr" Dram oz//16 false -"The grain, a US customary unit of mass defined as 32//875 dr. -\n\nDimension: [`Unitful.๐Œ`](@ref). -\n\nSee Also: [`Unitful.dr`](@ref)." +"`Unitful.gr` +\nThe grain, a US customary unit of mass defined as 32//875 dr. +\nDimension: [`Unitful.๐Œ`](@ref). +\nSee Also: [`Unitful.dr`](@ref)." @unit gr "gr" Grain (32//875)*dr false # Force -"The pound-force, a US customary unit of force defined as 1lb*ge. -\n\nDimension: ๐‹ ๐Œ ๐“^-2. -\n\nSee Also: [`Unitful.lb`](@ref), [`Unitful.ge`](@ref)." +"`Unitful.lbf` +\nThe pound-force, a US customary unit of force defined as 1lb*ge. +\nDimension: ๐‹ ๐Œ ๐“^-2. +\nSee Also: [`Unitful.lb`](@ref), [`Unitful.ge`](@ref)." @unit lbf "lbf" PoundsForce 1lb*ge false # Energy # Use ISO 31-4 for BTU definition -"The calorie, a unit of energy defined as exactly 4.184J. -\n\nDimension: ๐‹^2 ๐Œ ๐“^-2. -\n\nSee Also: [`Unitful.J`](@ref)." +"`Unitful.cal` +\nThe calorie, a unit of energy defined as exactly 4.184J. +\nDimension: ๐‹^2 ๐Œ ๐“^-2. +\nSee Also: [`Unitful.J`](@ref)." @unit cal "cal" Calorie 4.184J true -"The British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06J. -\n\nDimension: ๐‹^2 ๐Œ ๐“^-2. -\n\nSee Also: [`Unitful.J`](@ref)." +"`Unitful.btu` +\nThe British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06J. +\nDimension: ๐‹^2 ๐Œ ๐“^-2. +\nSee Also: [`Unitful.J`](@ref)." @unit btu "btu" BritishThermalUnit 1055.06J false # Pressure -"Pounds per square inch, a US customary unit of pressure defined as 1lbf/inch^2. -\n\nDimension: ๐Œ ๐‹^-1 ๐“^-2. -\n\nSee Also: [`Unitful.lbf`](@ref), [`Unitful.inch`](@ref)." +"`Unitful.psi` +\nPounds per square inch, a US customary unit of pressure defined as 1lbf/inch^2. +\nDimension: ๐Œ ๐‹^-1 ๐“^-2. +\nSee Also: [`Unitful.lbf`](@ref), [`Unitful.inch`](@ref)." @unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false ######### @@ -606,15 +711,17 @@ preferunits(kg) # others done in @refunit Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do for (k,v) in prefixdict sym = Symbol(v,:g) - docstring = "A prefixed unit, equal to 10^"*string(k-3)*" kg." + docstring = "`Unitful."*string(sym)*"`\n\n" + docstring *= "A prefixed unit, equal to 10^"*string(k-3)*" kg." docstring *= " Note that `kg`, not `g`, is the base unit." docstring *= "\n\nSee also: [`Unitful.kg`](@ref)." run = quote @doc $docstring $sym end eval(run) end - @doc "The kilogram, the SI base unit of mass. + @doc "`Unitful.kg` + \nThe kilogram, the SI base unit of mass. Note that `kg`, not `g`, is the base unit. - \n\nDimension: [`Unitful.๐Œ`](@ref)." kg + \nDimension: [`Unitful.๐Œ`](@ref)." kg end """ diff --git a/src/user.jl b/src/user.jl index b0447d42..ced8fd28 100644 --- a/src/user.jl +++ b/src/user.jl @@ -239,7 +239,7 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor) s = Symbol(v,symb) u = :($Unit{$n, $user_dimension}($k,1//1)) isbase = k==0 - docstring1 = "A prefixed unit, equal to 10^"*string(k)*" "*string(symb)*"." + docstring1 = "`"*string(__module__)*"."*string(s)*"`\n\nA prefixed unit, equal to 10^"*string(k)*" "*string(symb)*"." docstring1 *= "\n\nSee also: [`"*string(__module__)*"."*string(symb)*"`](@ref)." ea = quote $(basefactors_expr(__module__, n, basefactor)) From 84a2e28b64d85761c243df6ae22621116abc47ca Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 9 Oct 2021 16:41:57 -0500 Subject: [PATCH 14/43] Add NoDims documentation --- src/pkgdefaults.jl | 18 ++++++++++++------ src/types.jl | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index d8a6b645..daa656b1 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -96,13 +96,16 @@ const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T # Angles and solid angles "`Unitful.sr` -\nThe steradian, a unit of spherical angle. There are 4ฯ€ sr in a sphere." +\nThe steradian, a unit of spherical angle. There are 4ฯ€ sr in a sphere. +\nDImension: [`Unitful.NoDims`](@ref)." @unit sr "sr" Steradian 1 true "`Unitful.rad` -\nThe radian, a unit of angle. There are 2ฯ€ rad in a circle." +\nThe radian, a unit of angle. There are 2ฯ€ rad in a circle. +\nDImension: [`Unitful.NoDims`](@ref)." @unit rad "rad" Radian 1 true "`Unitful.ยฐ` -\nThe degree, a unit of angle. There are 360ยฐ in a circle." +\nThe degree, a unit of angle. There are 360ยฐ in a circle. +\nDImension: [`Unitful.NoDims`](@ref)." @unit ยฐ "ยฐ" Degree pi/180 false # For numerical accuracy, specific to the degree import Base: sind, cosd, tand, secd, cscd, cotd @@ -216,13 +219,16 @@ substrate per s. \nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." @unit kat "kat" Katal 1mol/s true "`Unitful.percent` -\nPercent, a unit meaning parts per hundred." +\nPercent, a unit meaning parts per hundred. +\nDImension: [`Unitful.NoDims`](@ref)." @unit percent "%" Percent 1//100 false "`Unitful.permille` -\nPermille, a unit meaning parts per thousand." +\nPermille, a unit meaning parts per thousand. +\nDImension: [`Unitful.NoDims`](@ref)." @unit permille "โ€ฐ" Permille 1//1000 false "`Unitful.pertenthousand` -\nPermyriad, a unit meaning parts per ten thousand." +\nPermyriad, a unit meaning parts per ten thousand. +\nDImension: [`Unitful.NoDims`](@ref)." @unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false # Temperature diff --git a/src/types.jl b/src/types.jl index 05b76f61..268ee757 100644 --- a/src/types.jl +++ b/src/types.jl @@ -27,6 +27,8 @@ end Instances of this object represent dimensions, possibly combinations thereof. """ struct Dimensions{N} <: Unitlike end +"`Unitful.NoDims` +\nA dimension representing quantities without dimensions." const NoDims = Dimensions{()}() """ From c04514d987ca87d4a4bcf981263f0352b65cae70 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 9 Oct 2021 17:22:10 -0500 Subject: [PATCH 15/43] Standardized number and equation format among quantity and unit docs --- src/pkgdefaults.jl | 161 +++++++++++++++++++++++---------------------- 1 file changed, 83 insertions(+), 78 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index daa656b1..52eb67c9 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -122,77 +122,77 @@ rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r)) # SI and related units "`Unitful.Hz` -\nThe hertz, an SI unit of frequency, defined as 1/s. +\nThe hertz, an SI unit of frequency, defined as 1 s^-1. \nDimension: ๐“^-1. \nSee also: [`Unitful.s`](@ref)." @unit Hz "Hz" Hertz 1/s true "`Unitful.N` -\nThe newton, an SI unit of force, defined as 1kg*m/s^2. +\nThe newton, an SI unit of force, defined as 1 kg ร— m / s^2. \nDimension: ๐‹ ๐Œ ๐“^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit N "N" Newton 1kg*m/s^2 true "`Unitful.Pa` -\nThe pascal, an SI unit of pressure, defined as 1N/m^2. +\nThe pascal, an SI unit of pressure, defined as 1 N / m^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." @unit Pa "Pa" Pascal 1N/m^2 true "`Unitful.J` -\nThe joule, an SI unit of energy, defined as 1N*m. +\nThe joule, an SI unit of energy, defined as 1 N ร— m. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." @unit J "J" Joule 1N*m true "`Unitful.W` -\nThe watt, an SI unit of power, defined as 1J/s. +\nThe watt, an SI unit of power, defined as 1 J / s. \nDimension: ๐‹^2 ๐Œ ๐“^-3. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." @unit W "W" Watt 1J/s true "`Unitful.C` -\nThe coulomb, an SI unit of electric charge, defined as 1A*s. +\nThe coulomb, an SI unit of electric charge, defined as 1 A ร— s. \nDimension: ๐ˆ ๐“. \nSee also: [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit C "C" Coulomb 1A*s true "`Unitful.V` -\nThe volt, an SI unit of electric potential, defined as 1W/A. +\nThe volt, an SI unit of electric potential, defined as 1 W / A. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-3. \nSee also: [`Unitful.W`](@ref), [`Unitful.A`](@ref)" @unit V "V" Volt 1W/A true "`Unitful.โ„ฆ` -\nThe ohm, an SI unit of electrical resistance, defined as 1V/A. +\nThe ohm, an SI unit of electrical resistance, defined as 1 V / A. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. \nSee also: [`Unitful.V`](@ref), [`Unitful.A`](@ref)." @unit ฮฉ "ฮฉ" Ohm 1V/A true "`Unitful.S` -\nThe siemens, an SI unit of electrical conductance, defined as 1/ฮฉ. +\nThe siemens, an SI unit of electrical conductance, defined as 1 ฮฉ^-1. \nDimension: ๐ˆ^2 ๐“^3 ๐‹^-2 ๐Œ^-1. \nSee also: [`Unitful.ฮฉ`](@ref)" @unit S "S" Siemens 1/ฮฉ true "`Unitful.F` -\nThe farad, an SI unit of electrical capacitance, defined as 1s^4*A^2/(kg*m^2). +\nThe farad, an SI unit of electrical capacitance, defined as 1 s^4 ร— A^2 / (kg ร— m^2). \nDimension: ๐ˆ^2 ๐“^4 ๐‹^-2 ๐Œ^-1. \nSee also: [`Unitful.s`](@ref), [`Unitful.A`](@ref), [`Unitful.kg`](@ref), [`Unitful.m`](@ref)." @unit F "F" Farad 1s^4*A^2/(kg*m^2) true "`Unitful.H` -\nThe henry, an SI unit of electrical inductance, defined as 1J/(A^2). +\nThe henry, an SI unit of electrical inductance, defined as 1 J / A^2. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-2. \nSee also: [`Unitful.J`](@ref), [`Unitful.A`](@ref)." @unit H "H" Henry 1J/(A^2) true "`Unitful.T` -\nThe tesla, an SI unit of magnetic B-field strength, defined as 1kg/(A*s^2). +\nThe tesla, an SI unit of magnetic B-field strength, defined as 1 kg / (A ร— s^2). \nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit T "T" Tesla 1kg/(A*s^2) true "`Unitful.Wb` -\nThe weber, an SI unit of magnetic flux, defined as 1kg*m^2/(A*s^2). +\nThe weber, an SI unit of magnetic flux, defined as 1 kg ร— m^2 / (A ร— s^2). \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true "`Unitful.lm` -\nThe lumen, an SI unit of luminous flux, defined as 1cd*sr. +\nThe lumen, an SI unit of luminous flux, defined as 1 cd ร— sr. \nDimension: ๐‰. \nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)." @unit lm "lm" Lumen 1cd*sr true "`Unitful.lx` -\nThe lux, an SI unit of illuminance, defined as 1lm/m^2. +\nThe lux, an SI unit of illuminance, defined as 1 lm / m^2. \nDimension: ๐‰ ๐‹^-2. \nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit lx "lx" Lux 1lm/m^2 true @@ -202,18 +202,18 @@ rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r)) \nSee also: [`Unitful.s`](@ref)." @unit Bq "Bq" Becquerel 1/s true "`Unitful.Gy` -\nThe gray, an SI unit of ionizing radiation dose, defined as the absorbtion of 1J per kg of matter. +\nThe gray, an SI unit of ionizing radiation dose, defined as the absorbtion of 1 J per kg of matter. \nDimension: ๐‹^2 ๐“^-2. \nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit Gy "Gy" Gray 1J/kg true "`Unitful.Sv` \nThe sievert, an SI unit of the biological effect of an ionizing radiation dose. -Defined as the health effect of 1Gy of radiation, scaled by a quality factor. +Defined as the health effect of 1 Gy of radiation, scaled by a quality factor. \nDimension: ๐‹^2 ๐“^-2. \nSee also: [`Unitful.Gy`](@ref)." @unit Sv "Sv" Sievert 1J/kg true "`Unitful.kat` -\nThe katal, an SI unit of catalytic activity, defined as 1mol of catalyzed +\nThe katal, an SI unit of catalytic activity, defined as 1 mol of catalyzed substrate per s. \nDimension: ๐ ๐“^-1. \nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." @@ -233,14 +233,14 @@ substrate per s. # Temperature "`Unitful.ยฐC` -\nThe degree Celsius, an SI unit of temperature, defined such that 0ยฐC = 273.15K. +\nThe degree Celsius, an SI unit of temperature, defined such that 0 ยฐC = 273.15 K. \nDimension: [`Unitful.๐šฏ`](@ref). \nSee also: [`Unitful.K`](@ref)." @affineunit ยฐC "ยฐC" (27315//100)K # Common units of time "`Unitful.minute` -\nThe minute, a unit of time defined as 60s. The full name `minute` is used instead of the symbol `min` +\nThe minute, a unit of time defined as 60 s. The full name `minute` is used instead of the symbol `min` to avoid confusion with the Julia function `min`. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.s`](@ref)." @@ -251,17 +251,17 @@ to avoid confusion with the Julia function `min`. \nSee Also: [`Unitful.minute`](@ref)." @unit hr "hr" Hour 3600s false "`Unitful.d` -\nThe day, a unit of time defined as 24hr. +\nThe day, a unit of time defined as 24 hr. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.hr`](@ref)." @unit d "d" Day 86400s false "`Unitful.wk` -\nThe week, a unit of time, defined as 7d. +\nThe week, a unit of time, defined as 7 d. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.d`](@ref)." @unit wk "wk" Week 604800s false "`Unitful.yr` -\nThe year, a unit of time, defined as 8766hr. +\nThe year, a unit of time, defined as 8766 hr. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.hr`](@ref)." @unit yr "yr" Year 31557600s true @@ -279,17 +279,17 @@ to avoid confusion with the Julia function `min`. # Area # The hectare is used more frequently than any other power-of-ten of an are. "`Unitful.a` -\nThe are, a metric unit of area, defined as 100m^2. +\nThe are, a metric unit of area, defined as 100 m^2. \nDimension: ๐‹^2. \nSee Also: [`Unitful.m`](@ref)." @unit a "a" Are 100m^2 false "`Unitful.ha` -\nThe hectare, a metric unit of area, defined as 100a. +\nThe hectare, a metric unit of area, defined as 100 a. \nDimension: ๐‹^2. \nSee Also: [`Unitful.a`](@ref)." const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, ๐‹^2}(2, 1//1),), ๐‹^2}() "`Unitful.b` -\nThe barn, a metric unit of area, defined as 100fm^2. +\nThe barn, a metric unit of area, defined as 100 fm^2. \nDimension: ๐‹^2. \nSee Also: [`Unitful.fm`](@ref)." @unit b "b" Barn 100fm^2 true @@ -297,7 +297,7 @@ const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, ๐‹^2}(2, 1//1),), ๐‹^2}() # Volume # `l` is also an acceptable symbol for liters "`Unitful.L` -\nThe liter, a metric unit of volume, defined as 1000cm^3. +\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 @@ -312,7 +312,7 @@ end # Molarity "`Unitful.M` -\nA unit for measuring molar concentration, a 1 molar solution has 1 mol of +\nA unit for measuring molar concentration; a 1 molar solution has 1 mol of solute per L of solution. \nDimension: ๐ ๐‹^-3. \nSee Also: [`Unitful.L`](@ref), [`Unitful.mol`](@ref)." @@ -321,7 +321,7 @@ solute per L of solution. # Energy "`Unitful.q` \nA quantity equal to the elementary charge, the charge of a single electron, -with a value of exactly 1.602176634 e-19 C. The letter `q` is used instead of `e` to avoid +with a value of exactly 1.602,176,634 ร— 10^-19 C. The letter `q` is used instead of `e` to avoid confusion with Euler's number. \nDimension: ๐ˆ ๐“. \nSee Also: [`Unitful.C`](@ref)." @@ -349,7 +349,7 @@ const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... \nSee also: [`Unitful.Pa`](@ref)." @unit atm "atm" Atmosphere 101325Pa false "`Unitful.Torr` -\nThe torr, a unit of pressure, defined as 1//760 atm. +\nThe torr, a unit of pressure, defined as 1/760 atm. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.atm`](@ref)." @unit Torr "Torr" Torr 101325Pa//760 true @@ -357,115 +357,120 @@ const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... # Constants (2018 CODATA values) (uncertainties in final digits) "`Unitful.c0` \nA quantity representing the speed of light in a vacuum, defined as exactly -299,792,458 m/s. +2.997,924,58 ร— 10^8 m/s. \nDimension: ๐‹ ๐“^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const c0 = 299_792_458*m/s # exact "`Unitful.c` \nThe speed of light in a vacuum, a unit of speed, defined as exactly -299,792,458 m/s. +2.997,924,58 ร— 10^8 m/s. \nDimension: ๐‹ ๐“^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit c "c" SpeedOfLight 1c0 false "`Unitful.ฮผ0` -\nA quantity representing the vacuum permeability constant, defined as 4ฯ€ * 1e-7 H/m. +\nA quantity representing the vacuum permeability constant, defined as 4ฯ€ ร— 10^-7 H / m. \nDimension: ๐‹ ๐Œ ๐ˆ^-2 ๐“^-2. \nSee also: [`Unitful.H`](@ref), [`Unitful.m`](@ref)." const ฮผ0 = 4ฯ€*(1//10)^7*H/m # exact (but gets promoted to Float64...) const ยต0 = ฮผ0 # magnetic constant "`Unitful.ฮต0` -\nA quantity representing the vacuum permittivity constant, defined as 1/(ฮผ0*c^2). +\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 const ฯต0 = ษ›0 # test of issue 79. "`Unitful.Z0` -\nA quantity representing the impedance of free space, a constant defined as ฮผ0*c. +\nA quantity representing the impedance of free space, a constant defined as ฮผ0 ร— c. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. \nSee also: [`Unitful.ฮผ0`](@ref), [`Unitful.c`](@ref)." const Z0 = ฮผ0*c # exact, impedance of free space "`Unitful.G` -\nA quantity representing the universal gravitational constant. +\nA quantity representing the universal gravitational constant, equal to +6.674,30 ร— 10^-11 m^3 / (kg ร— s^2) (the CODATA 2018 recommended value). \nDimension: ๐‹^3 ๐Œ^-1 ๐“^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.kg`](@ref), [`Unitful.s`](@ref)." const G = 6.674_30e-11*m^3/kg/s^2 # (15) gravitational constant "`Unitful.gn` \nA quantity representing the nominal acceleration due to gravity in a vacuum -near the surface of the earth, defined by standard to be exactly 9.80665 m/s^2. +near the surface of the earth, defined by standard to be exactly 9.806,65 m / s^2. \nDimension: ๐‹ ๐“^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const gn = 9.80665*m/s^2 # exact, standard acceleration of gravity "`Unitful.h` \nA quantity representing Planck's constant, defined as exactly -6.62607015 e-34 J*s. +6.62607015 ร— 10^-34 J*s. \nDimension: ๐‹^2 ๐Œ ๐“^-1. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." const h = 6.626_070_15e-34*J*s # exact, Planck constant "`Unitful.ฤง` -\nA quantity representing the reduced Planck constant, defined as h/(2ฯ€). +\nA quantity representing the reduced Planck constant, defined as h / (2 ฯ€). \nDimension: ๐‹^2 ๐Œ ๐“^-1. \nSee also: [`Unitful.h`](@ref)." const ฤง = h/2ฯ€ # hbar "`Unitful.ฮฆ0` \nA quantity representing the superconducting magnetic flux quantum, defined as -h/(2q). +h / (2 q). \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.h`](@ref), [`Unitful.q`](@ref)." const ฮฆ0 = h/(2q) # Superconducting magnetic flux quantum "`Unitful.me` -\nA quantity representing the rest mass of an electron, given to 11 significant figures. +\nA quantity representing the rest mass of an electron, equal to 9.109,383,7015 +ร— 10^-31 kg (the CODATA 2018 recommended value). \nDimension: ๐Œ. \nSee also: [`Unitful.kg`](@ref)." const me = 9.109_383_7015e-31*kg # (28) electron rest mass "`Unitful.mn` -\nA quantity representing the rest mass of a neutron, given to 12 significant figures. +\nA quantity representing the rest mass of a neutron, equal to 1.674,927,498,04 +ร— 10^-27 kg (the CODATA 2018 recommended value). \nDimension: ๐Œ. \nSee also: [`Unitful.kg`](@ref)." const mn = 1.674_927_498_04e-27*kg # (95) neutron rest mass "`Unitful.mp` -\nA quantity representing the rest mass of a proton, given to 12 significant figures. +\nA quantity representing the rest mass of a proton, equal to 1.672,621,923,69 +ร— 10^-27 kg (the CODATA 2018 recommended value). \nDimension: ๐Œ. \nSee also: [`Unitful.kg`](@ref)." const mp = 1.672_621_923_69e-27*kg # (51) proton rest mass "`Unitful.ฮผB` -\nA quantity representing the Bohr magneton, given to 11 significant figures. +\nA quantity representing the Bohr magneton, equal to q ร— ฤง / (2 ร— me). \nDimension: ๐ˆ ๐‹^2. \nSee also: [`Unitful.q`](@ref), [`Unitful.ฤง`](@ref), [`Unitful.me`](@ref)." const ฮผB = q*ฤง/(2*me) # Bohr magneton const ยตB = ฮผB "`Unitful.Na` \nA quantity representing Avogadro's constant, defined as exactly -6.02214076 e23 / mol. +6.022,140,76 ร— 10^23 / mol. \nDimension: ๐^-1. \nSee also: [`Unitful.mol`](@ref)." const Na = 6.022_140_76e23/mol # exact, Avogadro constant "`Unitful.k` \nA quantity representing the Boltzmann constant, defined as exactly -1.380649 e-23 J/K. +1.380,649 ร— 10^-23 J / K. \nDimension: ๐‹^2 ๐Œ ๐šฏ^-1 ๐“^-2. \nSee also: [`Unitful.J`](@ref), [`Unitful.K`](@ref)." const k = 1.380_649e-23*(J/K) # exact, Boltzmann constant "`Unitful.R` \nA quantity representing the molar gas constant, defined as -Na*k. +Na ร— k. \nDimension: ๐‹^2 ๐Œ ๐^-1 ๐šฏ^-1 ๐“^-2. \nSee also: [`Unitful.Na`](@ref), [`Unitful.k`](@ref)." const R = Na*k # molar gas constant "`Unitful.ฯƒ` \nA quantity representing the Stefan-Boltzmann constant, defined as -ฯ€^2*k^4/(60*ฤง^3*c^2). +ฯ€^2 ร— k^4 / (60 ร— ฤง^3 ร— c^2). \nDimension: ๐Œ ๐šฏ^-4 ๐“^-3. \nSee also: [`Unitful.k`](@ref), [`Unitful.ฤง`](@ref), [`Unitful.c`](@ref)." const ฯƒ = ฯ€^2*k^4/(60*ฤง^3*c^2) # Stefan-Boltzmann constant "`Unitful.Rโˆž` -\nA quantity representing the Bohr magneton, given to 14 significant figures. +\nA quantity representing the Rydberg constant, equal to 1.097,373,156,8160 ร— 10^-7 / m +(the CODATA 2018 recommended value). \nDimension: ๐‹^-1. \nSee also: [`Unitful.m`](@ref)." const Rโˆž = 10_973_731.568_160/m # (21) Rydberg constant "`Unitful.u` -\nThe unified atomic mass unit, or dalton, a unit of mass defined as 1//12 the -mass of an unbound neutral atom of carbon-12. It is defined here to 12 -significant figures. +\nThe unified atomic mass unit, or dalton, a unit of mass defined as 1/12 the +mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 ร— kg +(the CODATA 2018 recommended value). \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.kg`](@ref)." @unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false # (50) @@ -473,7 +478,7 @@ significant figures. # Acceleration "`Unitful.ge` \nThe nominal acceleration due to gravity in a vacuum near the surface of the -earth, a unit of acceleration, defined by standard to be exactly 9.80665 m/s^2. +earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^2. \nDimension: ๐‹ ๐“^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit ge "ge" EarthGravity gn false @@ -481,47 +486,47 @@ earth, a unit of acceleration, defined by standard to be exactly 9.80665 m/s^2. # CGS units "`Unitful.Gal` -\nThe gal, a CGS unit of acceleration, defined as 1cm/s^2. +\nThe gal, a CGS unit of acceleration, defined as 1 cm / s^2. \nDimension: ๐‹ ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)." @unit Gal "Gal" Gal 1cm/s^2 true "`Unitful.dyn` -\nThe dyne, a CGS unit of force, defined as 1g*cm/s^2. +\nThe dyne, a CGS unit of force, defined as 1 g ร— cm / s^2. \nDimension: ๐‹ ๐Œ ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref), [`Unitful.g`](@ref)." @unit dyn "dyn" Dyne 1g*cm/s^2 true "`Unitful.erg` -\nThe erg, a CGS unit of energy, defined as 1dyn*cm. +\nThe erg, a CGS unit of energy, defined as 1 dyn ร— cm. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" @unit erg "erg" Erg 1g*cm^2/s^2 true "`Unitful.Ba` -\nThe barye, a CGS unit of pressure, defined as 1dyn/cm^2. +\nThe barye, a CGS unit of pressure, defined as 1 dyn / cm^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" @unit Ba "Ba" Barye 1g/cm/s^2 true "`Unitful.P` -\nThe poise, a CGS unit of dynamic viscosity, defined as 1dyn*s/cm^2. +\nThe poise, a CGS unit of dynamic viscosity, defined as 1 dyn ร— s / cm^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-1. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref), [`Unitful.s`](@ref)" @unit P "P" Poise 1g/cm/s true "`Unitful.St` -\nThe stokes, a CGS unit of kinematic viscosity, defined as 1cm^2/s. +\nThe stokes, a CGS unit of kinematic viscosity, defined as 1 cm^2 / s. \nDimension: ๐Œ^2 ๐“^-1. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)" @unit St "St" Stokes 1cm^2/s true "`Unitful.Gauss` -\nThe gauss, a CGS unit of magnetic B-field strength, defined as 1Mx/cm^2. +\nThe gauss, a CGS unit of magnetic B-field strength, defined as 1 Mx / cm^2. \nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.Mx`](@ref)" @unit Gauss "Gauss" Gauss (1//10_000)*T true "`Unitful.Oe` -\nThe oersted, a CGS unit of magnetic H-field strength, defined as (1_000/4ฯ€)A/m. +\nThe oersted, a CGS unit of magnetic H-field strength, defined as 1,000 ร— A / (4ฯ€ ร— m). \nDimension: ๐ˆ ๐‹^-1. \nSee also: [`Unitful.A`](@ref), [`Unitful.m`](@ref)" @unit Oe "Oe" Oersted (1_000/4ฯ€)*A/m true "`Unitful.Mx` -\nThe maxwell, a CGS unit of magnetic flux, defined as 1Gauss*cm^2. +\nThe maxwell, a CGS unit of magnetic flux, defined as 1 Gauss ร— cm^2. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.Gauss`](@ref)" @unit Mx "Mx" Maxwell (1//100_000_000)*Wb true @@ -533,12 +538,12 @@ earth, a unit of acceleration, defined by standard to be exactly 9.80665 m/s^2. # Length #key: Symbol Display Name Equivalent to 10^n prefixes? "`Unitful.inch` -\nThe inch, a US customary unit of length defined as 254//10000 m. +\nThe inch, a US customary unit of length defined as 254/10000 m. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.m`](@ref)." @unit inch "inch" Inch (254//10000)*m false "`Unitful.mil` -\nThe mil, a US customary unit of length defined as 1//1000 inch. +\nThe mil, a US customary unit of length defined as 1/1000 inch. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.inch`](@ref)." @unit mil "mil" Mil (1//1000)*inch false @@ -557,13 +562,13 @@ earth, a unit of acceleration, defined by standard to be exactly 9.80665 m/s^2. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.yd`](@ref)." @unit mi "mi" Mile 1760yd false -"`Unitful.โ„ซ` -\nThe angstrom, a metric unit of length defined as 1//10 nm. +"`Unitful.angstrom` +\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 # U+00c5 (opt-shift-A on macOS) and U+212b ('\Angstrom' in REPL) look identical: -const ร… = โ„ซ = angstrom +@doc @doc(angstrom) const ร… = โ„ซ = angstrom # Area "`Unitful.ac` @@ -574,46 +579,46 @@ const ร… = โ„ซ = angstrom # Temperatures "`Unitful.Ra` -\nThe rankine, a US customary unit of temperature defined as 5//9 K. +\nThe rankine, a US customary unit of temperature defined as 5/9 K. \nDimension: [`Unitful.๐šฏ`](@ref). \nSee Also: [`Unitful.K`](@ref)." @unit Ra "Ra" Rankine (5//9)*K false "`Unitful.ยฐF` -\nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0ยฐF = 459.67Ra. +\nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0ยฐ F = 459.67 Ra. \nDimension: [`Unitful.๐šฏ`](@ref). \nSee also: [`Unitful.Ra`](@ref)." @affineunit ยฐF "ยฐF" (45967//100)Ra # Masses "`Unitful.lb` -\nThe pound-mass, a US customary unit of mass defined as exactly 0.45359237kg. +\nThe pound-mass, a US customary unit of mass defined as exactly 0.453,592,37 kg. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.kg`](@ref)." @unit lb "lb" Pound 0.45359237kg false # is exact "`Unitful.oz` -\nThe ounce, a US customary unit of mass defined as 1//16 lb. +\nThe ounce, a US customary unit of mass defined as 1/16 lb. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lb`](@ref)." @unit oz "oz" Ounce lb//16 false "`Unitful.slug` -\nThe slug, a US customary unit of mass defined as 1lbf*s^2/ft. +\nThe slug, a US customary unit of mass defined as 1 lbf ร— s^2 / ft. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.s`](@ref), [`Unitful.ft`](@ref)." @unit slug "slug" Slug 1lb*ge*s^2/ft false "`Unitful.dr` -\nThe dram, a US customary unit of mass defined as 1//16 oz. +\nThe dram, a US customary unit of mass defined as 1/16 oz. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.oz`](@ref)." @unit dr "dr" Dram oz//16 false "`Unitful.gr` -\nThe grain, a US customary unit of mass defined as 32//875 dr. +\nThe grain, a US customary unit of mass defined as 32/875 dr. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.dr`](@ref)." @unit gr "gr" Grain (32//875)*dr false # Force "`Unitful.lbf` -\nThe pound-force, a US customary unit of force defined as 1lb*ge. +\nThe pound-force, a US customary unit of force defined as 1 lb ร— ge. \nDimension: ๐‹ ๐Œ ๐“^-2. \nSee Also: [`Unitful.lb`](@ref), [`Unitful.ge`](@ref)." @unit lbf "lbf" PoundsForce 1lb*ge false @@ -621,19 +626,19 @@ const ร… = โ„ซ = angstrom # Energy # Use ISO 31-4 for BTU definition "`Unitful.cal` -\nThe calorie, a unit of energy defined as exactly 4.184J. +\nThe calorie, a unit of energy defined as exactly 4.184 J. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee Also: [`Unitful.J`](@ref)." @unit cal "cal" Calorie 4.184J true "`Unitful.btu` -\nThe British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06J. +\nThe British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06 J. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee Also: [`Unitful.J`](@ref)." @unit btu "btu" BritishThermalUnit 1055.06J false # Pressure "`Unitful.psi` -\nPounds per square inch, a US customary unit of pressure defined as 1lbf/inch^2. +\nPounds per square inch, a US customary unit of pressure defined as 1 lbf / inch^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.inch`](@ref)." @unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false From 3c26bfe7be6add19e5a44728a64541a0f07117f7 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 9 Oct 2021 17:24:37 -0500 Subject: [PATCH 16/43] Standardize format of dimensions in unit docs --- src/pkgdefaults.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 52eb67c9..29a04a76 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -188,7 +188,7 @@ rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r)) @unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true "`Unitful.lm` \nThe lumen, an SI unit of luminous flux, defined as 1 cd ร— sr. -\nDimension: ๐‰. +\nDimension: [`Unitful.๐‰`](@ref). \nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)." @unit lm "lm" Lumen 1cd*sr true "`Unitful.lx` @@ -416,19 +416,19 @@ const ฮฆ0 = h/(2q) # Superconducting magnetic flux quantum "`Unitful.me` \nA quantity representing the rest mass of an electron, equal to 9.109,383,7015 ร— 10^-31 kg (the CODATA 2018 recommended value). -\nDimension: ๐Œ. +\nDimension: [`Unitful.๐Œ`](@ref). \nSee also: [`Unitful.kg`](@ref)." const me = 9.109_383_7015e-31*kg # (28) electron rest mass "`Unitful.mn` \nA quantity representing the rest mass of a neutron, equal to 1.674,927,498,04 ร— 10^-27 kg (the CODATA 2018 recommended value). -\nDimension: ๐Œ. +\nDimension: [`Unitful.๐Œ`](@ref). \nSee also: [`Unitful.kg`](@ref)." const mn = 1.674_927_498_04e-27*kg # (95) neutron rest mass "`Unitful.mp` \nA quantity representing the rest mass of a proton, equal to 1.672,621,923,69 ร— 10^-27 kg (the CODATA 2018 recommended value). -\nDimension: ๐Œ. +\nDimension: [`Unitful.๐Œ`](@ref). \nSee also: [`Unitful.kg`](@ref)." const mp = 1.672_621_923_69e-27*kg # (51) proton rest mass "`Unitful.ฮผB` From d51fd85dee2e8c96a63d6e14a4c37df7388c2343 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Mon, 11 Oct 2021 11:48:44 -0600 Subject: [PATCH 17/43] Apply suggestions from code review Various minor fixes and changes, mostly typos and format changes. Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/pkgdefaults.jl | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 29a04a76..28c721b8 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -97,15 +97,15 @@ const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T # Angles and solid angles "`Unitful.sr` \nThe steradian, a unit of spherical angle. There are 4ฯ€ sr in a sphere. -\nDImension: [`Unitful.NoDims`](@ref)." +\nDimension: [`Unitful.NoDims`](@ref)." @unit sr "sr" Steradian 1 true "`Unitful.rad` \nThe radian, a unit of angle. There are 2ฯ€ rad in a circle. -\nDImension: [`Unitful.NoDims`](@ref)." +\nDimension: [`Unitful.NoDims`](@ref)." @unit rad "rad" Radian 1 true "`Unitful.ยฐ` \nThe degree, a unit of angle. There are 360ยฐ in a circle. -\nDImension: [`Unitful.NoDims`](@ref)." +\nDimension: [`Unitful.NoDims`](@ref)." @unit ยฐ "ยฐ" Degree pi/180 false # For numerical accuracy, specific to the degree import Base: sind, cosd, tand, secd, cscd, cotd @@ -220,15 +220,15 @@ substrate per s. @unit kat "kat" Katal 1mol/s true "`Unitful.percent` \nPercent, a unit meaning parts per hundred. -\nDImension: [`Unitful.NoDims`](@ref)." +\nDimension: [`Unitful.NoDims`](@ref)." @unit percent "%" Percent 1//100 false "`Unitful.permille` \nPermille, a unit meaning parts per thousand. -\nDImension: [`Unitful.NoDims`](@ref)." +\nDimension: [`Unitful.NoDims`](@ref)." @unit permille "โ€ฐ" Permille 1//1000 false "`Unitful.pertenthousand` \nPermyriad, a unit meaning parts per ten thousand. -\nDImension: [`Unitful.NoDims`](@ref)." +\nDimension: [`Unitful.NoDims`](@ref)." @unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false # Temperature @@ -261,19 +261,19 @@ to avoid confusion with the Julia function `min`. \nSee Also: [`Unitful.d`](@ref)." @unit wk "wk" Week 604800s false "`Unitful.yr` -\nThe year, a unit of time, defined as 8766 hr. +\nThe year, a unit of time, defined as 365.25 d. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.hr`](@ref)." @unit yr "yr" Year 31557600s true "`Unitful.rps` -\nRevolutions per second, a unit of rotational speed, defined as one rotation per s. +\nRevolutions per second, a unit of rotational speed, defined as 2ฯ€ rad / s. \nDimension: ๐“^-1. -\nSee Also: [`Unitful.s`](@ref)." +\nSee Also: [`Unitful.rad`](@ref), [`Unitful.s`](@ref)." @unit rps "rps" RevolutionsPerSecond 2ฯ€*rad/s false "`Unitful.rpm` -\nRevolutions per minute, a unit of rotational speed, defined as one rotation per minute. +\nRevolutions per minute, a unit of rotational speed, defined as 2ฯ€ rad / minute. \nDimension: ๐“^-1. -\nSee Also: [`Unitful.minute`](@ref)." +\nSee Also: [`Unitful.minute`](@ref), [`Unitful.rad`](@ref)." @unit rpm "rpm" RevolutionsPerMinute 2ฯ€*rad/minute false # Area @@ -469,7 +469,7 @@ const ฯƒ = ฯ€^2*k^4/(60*ฤง^3*c^2) # Stefan-Boltzmann constant const Rโˆž = 10_973_731.568_160/m # (21) Rydberg constant "`Unitful.u` \nThe unified atomic mass unit, or dalton, a unit of mass defined as 1/12 the -mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 ร— kg +mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 ร— 10^-27 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.kg`](@ref)." @@ -584,7 +584,7 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nSee Also: [`Unitful.K`](@ref)." @unit Ra "Ra" Rankine (5//9)*K false "`Unitful.ยฐF` -\nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0ยฐ F = 459.67 Ra. +\nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0 ยฐF = 459.67 Ra. \nDimension: [`Unitful.๐šฏ`](@ref). \nSee also: [`Unitful.Ra`](@ref)." @affineunit ยฐF "ยฐF" (45967//100)Ra @@ -611,9 +611,9 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nSee Also: [`Unitful.oz`](@ref)." @unit dr "dr" Dram oz//16 false "`Unitful.gr` -\nThe grain, a US customary unit of mass defined as 32/875 dr. +\nThe grain, a US customary unit of mass defined as 1/7000 lb. \nDimension: [`Unitful.๐Œ`](@ref). -\nSee Also: [`Unitful.dr`](@ref)." +\nSee Also: [`Unitful.lb`](@ref)." @unit gr "gr" Grain (32//875)*dr false # Force From 0b057dc962246f35da9d7ab98a4b9b14cea71b5f Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Mon, 11 Oct 2021 14:11:37 -0500 Subject: [PATCH 18/43] Switch from inline to block code blocks in new docstrings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also standardize docstrings to `2ฯ€` for 2 pi. --- src/pkgdefaults.jl | 216 ++++++++++++++++++++++----------------------- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 28c721b8..d2c69ebd 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -2,25 +2,25 @@ # The dimension symbols are generated by tab completion: \bfL is ๐‹, etc. # At the expense of easy typing, this gives a visual cue to distinguish # dimensions from units, and also helps prevent common namespace collisions. -"`Unitful.๐‹` +" Unitful.๐‹ \nA dimension representing length." @dimension ๐‹ "๐‹" Length -"`Unitful.๐Œ` +" Unitful.๐Œ \nA dimension representing mass." @dimension ๐Œ "๐Œ" Mass -"`Unitful.๐“` +" Unitful.๐“ \nA dimension representing time." @dimension ๐“ "๐“" Time -"`Unitful.๐ˆ` +" Unitful.๐ˆ \nA dimension representing electric current." @dimension ๐ˆ "๐ˆ" Current -"`Unitful.๐šฏ` +" Unitful.๐šฏ \nA dimension representing thermodynamic temperature." @dimension ๐šฏ "๐šฏ" Temperature # This one is \bfTheta -"`Unitful.๐‰` +" Unitful.๐‰ \nA dimension representing luminous intensity." @dimension ๐‰ "๐‰" Luminosity -"`Unitful.๐` +" Unitful.๐ \nA dimension representing amount of substance." @dimension ๐ "๐" Amount const RelativeScaleTemperature = Quantity{T, ๐šฏ, <:AffineUnits} where T @@ -67,43 +67,43 @@ const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T # Define base units. This is not to imply g is the base SI unit instead of kg. # See the documentation for further details. # #key: Symbol Display Name Dimension Prefixes? -"`Unitful.m` +" Unitful.m \nThe meter, the SI base unit of length. \nDimension: [`Unitful.๐‹`](@ref)." @refunit m "m" Meter ๐‹ true -"`Unitful.s` +" Unitful.s \nThe second, the SI base unit of time. \nDimension: [`Unitful.๐“`](@ref)." @refunit s "s" Second ๐“ true -"`Unitful.A` +" Unitful.A \nThe ampere, the SI base unit of electric current. \nDimension: [`Unitful.๐ˆ`](@ref)." @refunit A "A" Ampere ๐ˆ true -"`Unitful.K` +" Unitful.K \nThe kelvin, the SI base unit of thermodynamic temperature. \nDimension: [`Unitful.๐šฏ`](@ref)." @refunit K "K" Kelvin ๐šฏ true -"`Unitful.cd` +" Unitful.cd \nThe candela, the SI base unit of luminous intensity. \nDimension: [`Unitful.๐‰`](@ref)." @refunit cd "cd" Candela ๐‰ true # the docs for all gram-based units are defined later, to ensure kg is the base unit. @refunit g "g" Gram ๐Œ true -"`Unitful.mol` +" Unitful.mol \nThe mole, the SI base unit for amount of substance. \nDimension: [`Unitful.๐`](@ref)." @refunit mol "mol" Mole ๐ true # Angles and solid angles -"`Unitful.sr` +" Unitful.sr \nThe steradian, a unit of spherical angle. There are 4ฯ€ sr in a sphere. \nDimension: [`Unitful.NoDims`](@ref)." @unit sr "sr" Steradian 1 true -"`Unitful.rad` +" Unitful.rad \nThe radian, a unit of angle. There are 2ฯ€ rad in a circle. \nDimension: [`Unitful.NoDims`](@ref)." @unit rad "rad" Radian 1 true -"`Unitful.ยฐ` +" Unitful.ยฐ \nThe degree, a unit of angle. There are 360ยฐ in a circle. \nDimension: [`Unitful.NoDims`](@ref)." @unit ยฐ "ยฐ" Degree pi/180 false @@ -121,156 +121,156 @@ deg2rad(d::Quantity{T, NoDims, typeof(ยฐ)}) where {T} = deg2rad(ustrip(ยฐ, d))u" rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r))u"ยฐ" # SI and related units -"`Unitful.Hz` +" Unitful.Hz \nThe hertz, an SI unit of frequency, defined as 1 s^-1. \nDimension: ๐“^-1. \nSee also: [`Unitful.s`](@ref)." @unit Hz "Hz" Hertz 1/s true -"`Unitful.N` +" Unitful.N \nThe newton, an SI unit of force, defined as 1 kg ร— m / s^2. \nDimension: ๐‹ ๐Œ ๐“^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit N "N" Newton 1kg*m/s^2 true -"`Unitful.Pa` +" Unitful.Pa \nThe pascal, an SI unit of pressure, defined as 1 N / m^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." @unit Pa "Pa" Pascal 1N/m^2 true -"`Unitful.J` +" Unitful.J \nThe joule, an SI unit of energy, defined as 1 N ร— m. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." @unit J "J" Joule 1N*m true -"`Unitful.W` +" Unitful.W \nThe watt, an SI unit of power, defined as 1 J / s. \nDimension: ๐‹^2 ๐Œ ๐“^-3. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." @unit W "W" Watt 1J/s true -"`Unitful.C` +" Unitful.C \nThe coulomb, an SI unit of electric charge, defined as 1 A ร— s. \nDimension: ๐ˆ ๐“. \nSee also: [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit C "C" Coulomb 1A*s true -"`Unitful.V` +" Unitful.V \nThe volt, an SI unit of electric potential, defined as 1 W / A. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-3. \nSee also: [`Unitful.W`](@ref), [`Unitful.A`](@ref)" @unit V "V" Volt 1W/A true -"`Unitful.โ„ฆ` +" Unitful.โ„ฆ \nThe ohm, an SI unit of electrical resistance, defined as 1 V / A. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. \nSee also: [`Unitful.V`](@ref), [`Unitful.A`](@ref)." @unit ฮฉ "ฮฉ" Ohm 1V/A true -"`Unitful.S` +" Unitful.S \nThe siemens, an SI unit of electrical conductance, defined as 1 ฮฉ^-1. \nDimension: ๐ˆ^2 ๐“^3 ๐‹^-2 ๐Œ^-1. \nSee also: [`Unitful.ฮฉ`](@ref)" @unit S "S" Siemens 1/ฮฉ true -"`Unitful.F` +" Unitful.F \nThe farad, an SI unit of electrical capacitance, defined as 1 s^4 ร— A^2 / (kg ร— m^2). \nDimension: ๐ˆ^2 ๐“^4 ๐‹^-2 ๐Œ^-1. \nSee also: [`Unitful.s`](@ref), [`Unitful.A`](@ref), [`Unitful.kg`](@ref), [`Unitful.m`](@ref)." @unit F "F" Farad 1s^4*A^2/(kg*m^2) true -"`Unitful.H` +" Unitful.H \nThe henry, an SI unit of electrical inductance, defined as 1 J / A^2. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-2. \nSee also: [`Unitful.J`](@ref), [`Unitful.A`](@ref)." @unit H "H" Henry 1J/(A^2) true -"`Unitful.T` +" Unitful.T \nThe tesla, an SI unit of magnetic B-field strength, defined as 1 kg / (A ร— s^2). \nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit T "T" Tesla 1kg/(A*s^2) true -"`Unitful.Wb` +" Unitful.Wb \nThe weber, an SI unit of magnetic flux, defined as 1 kg ร— m^2 / (A ร— s^2). \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." @unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true -"`Unitful.lm` +" Unitful.lm \nThe lumen, an SI unit of luminous flux, defined as 1 cd ร— sr. \nDimension: [`Unitful.๐‰`](@ref). \nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)." @unit lm "lm" Lumen 1cd*sr true -"`Unitful.lx` +" Unitful.lx \nThe lux, an SI unit of illuminance, defined as 1 lm / m^2. \nDimension: ๐‰ ๐‹^-2. \nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit lx "lx" Lux 1lm/m^2 true -"`Unitful.Bq` +" Unitful.Bq \nThe becquerel, an SI unit of radioactivity, defined as 1 nuclear decay per s. \nDimension: ๐“^-1. \nSee also: [`Unitful.s`](@ref)." @unit Bq "Bq" Becquerel 1/s true -"`Unitful.Gy` +" Unitful.Gy \nThe gray, an SI unit of ionizing radiation dose, defined as the absorbtion of 1 J per kg of matter. \nDimension: ๐‹^2 ๐“^-2. \nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." @unit Gy "Gy" Gray 1J/kg true -"`Unitful.Sv` +" Unitful.Sv \nThe sievert, an SI unit of the biological effect of an ionizing radiation dose. Defined as the health effect of 1 Gy of radiation, scaled by a quality factor. \nDimension: ๐‹^2 ๐“^-2. \nSee also: [`Unitful.Gy`](@ref)." @unit Sv "Sv" Sievert 1J/kg true -"`Unitful.kat` +" Unitful.kat \nThe katal, an SI unit of catalytic activity, defined as 1 mol of catalyzed substrate per s. \nDimension: ๐ ๐“^-1. \nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." @unit kat "kat" Katal 1mol/s true -"`Unitful.percent` +" Unitful.percent \nPercent, a unit meaning parts per hundred. \nDimension: [`Unitful.NoDims`](@ref)." @unit percent "%" Percent 1//100 false -"`Unitful.permille` +" Unitful.permille \nPermille, a unit meaning parts per thousand. \nDimension: [`Unitful.NoDims`](@ref)." @unit permille "โ€ฐ" Permille 1//1000 false -"`Unitful.pertenthousand` +" Unitful.pertenthousand \nPermyriad, a unit meaning parts per ten thousand. \nDimension: [`Unitful.NoDims`](@ref)." @unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false # Temperature -"`Unitful.ยฐC` +" Unitful.ยฐC \nThe degree Celsius, an SI unit of temperature, defined such that 0 ยฐC = 273.15 K. \nDimension: [`Unitful.๐šฏ`](@ref). \nSee also: [`Unitful.K`](@ref)." @affineunit ยฐC "ยฐC" (27315//100)K # Common units of time -"`Unitful.minute` +" Unitful.minute \nThe minute, a unit of time defined as 60 s. The full name `minute` is used instead of the symbol `min` to avoid confusion with the Julia function `min`. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.s`](@ref)." @unit minute "minute" Minute 60s false -"`Unitful.hr` +" Unitful.hr \nThe hour, a unit of time defined as 60 minutes. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.minute`](@ref)." @unit hr "hr" Hour 3600s false -"`Unitful.d` +" Unitful.d \nThe day, a unit of time defined as 24 hr. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.hr`](@ref)." @unit d "d" Day 86400s false -"`Unitful.wk` +" Unitful.wk \nThe week, a unit of time, defined as 7 d. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.d`](@ref)." @unit wk "wk" Week 604800s false -"`Unitful.yr` +" Unitful.yr \nThe year, a unit of time, defined as 365.25 d. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.hr`](@ref)." @unit yr "yr" Year 31557600s true -"`Unitful.rps` +" Unitful.rps \nRevolutions per second, a unit of rotational speed, defined as 2ฯ€ rad / s. \nDimension: ๐“^-1. \nSee Also: [`Unitful.rad`](@ref), [`Unitful.s`](@ref)." @unit rps "rps" RevolutionsPerSecond 2ฯ€*rad/s false -"`Unitful.rpm` +" Unitful.rpm \nRevolutions per minute, a unit of rotational speed, defined as 2ฯ€ rad / minute. \nDimension: ๐“^-1. \nSee Also: [`Unitful.minute`](@ref), [`Unitful.rad`](@ref)." @@ -278,17 +278,17 @@ to avoid confusion with the Julia function `min`. # Area # The hectare is used more frequently than any other power-of-ten of an are. -"`Unitful.a` +" Unitful.a \nThe are, a metric unit of area, defined as 100 m^2. \nDimension: ๐‹^2. \nSee Also: [`Unitful.m`](@ref)." @unit a "a" Are 100m^2 false -"`Unitful.ha` +" Unitful.ha \nThe hectare, a metric unit of area, defined as 100 a. \nDimension: ๐‹^2. \nSee Also: [`Unitful.a`](@ref)." const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, ๐‹^2}(2, 1//1),), ๐‹^2}() -"`Unitful.b` +" Unitful.b \nThe barn, a metric unit of area, defined as 100 fm^2. \nDimension: ๐‹^2. \nSee Also: [`Unitful.fm`](@ref)." @@ -296,7 +296,7 @@ const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, ๐‹^2}(2, 1//1),), ๐‹^2}() # Volume # `l` is also an acceptable symbol for liters -"`Unitful.L` +" Unitful.L \nThe liter, a metric unit of volume, defined as 1000 cm^3. \nDimension: ๐‹^3. \nSee Also: [`Unitful.cm`](@ref)." @@ -311,7 +311,7 @@ for p in (:y, :z, :a, :f, :p, :n, :ฮผ, :ยต, :m, :c, :d, end # Molarity -"`Unitful.M` +" Unitful.M \nA unit for measuring molar concentration; a 1 molar solution has 1 mol of solute per L of solution. \nDimension: ๐ ๐‹^-3. @@ -319,155 +319,155 @@ solute per L of solution. @unit M "M" Molar 1mol/L true # Energy -"`Unitful.q` +" Unitful.q \nA quantity equal to the elementary charge, the charge of a single electron, with a value of exactly 1.602,176,634 ร— 10^-19 C. The letter `q` is used instead of `e` to avoid confusion with Euler's number. \nDimension: ๐ˆ ๐“. \nSee Also: [`Unitful.C`](@ref)." const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... -"`Unitful.eV` +" Unitful.eV \nThe electron-volt, a unit of energy, defined as q*V. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee also: [`Unitful.q`](@ref), [`Unitful.V`](@ref)." @unit eV "eV" eV q*V true # For convenience -"`Unitful.Hz2ฯ€` +" Unitful.Hz2ฯ€ \nA unit for convenience in angular frequency, equal to 2ฯ€ Hz. \nDimension: ๐“^-1. \nSee also: [`Unitful.Hz`](@ref)." @unit Hz2ฯ€ "Hz2ฯ€" AngHertz 2ฯ€/s true -"`Unitful.bar` +" Unitful.bar \nThe bar, a metric unit of pressure, defined as 100 kPa. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.kPa`](@ref)." @unit bar "bar" Bar 100000Pa true -"`Unitful.atm` +" Unitful.atm \nThe standard atmosphere, a unit of pressure, defined as 101,325 Pa. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.Pa`](@ref)." @unit atm "atm" Atmosphere 101325Pa false -"`Unitful.Torr` +" Unitful.Torr \nThe torr, a unit of pressure, defined as 1/760 atm. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.atm`](@ref)." @unit Torr "Torr" Torr 101325Pa//760 true # Constants (2018 CODATA values) (uncertainties in final digits) -"`Unitful.c0` +" Unitful.c0 \nA quantity representing the speed of light in a vacuum, defined as exactly 2.997,924,58 ร— 10^8 m/s. \nDimension: ๐‹ ๐“^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const c0 = 299_792_458*m/s # exact -"`Unitful.c` +" Unitful.c \nThe speed of light in a vacuum, a unit of speed, defined as exactly 2.997,924,58 ร— 10^8 m/s. \nDimension: ๐‹ ๐“^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit c "c" SpeedOfLight 1c0 false -"`Unitful.ฮผ0` +" Unitful.ฮผ0 \nA quantity representing the vacuum permeability constant, defined as 4ฯ€ ร— 10^-7 H / m. \nDimension: ๐‹ ๐Œ ๐ˆ^-2 ๐“^-2. \nSee also: [`Unitful.H`](@ref), [`Unitful.m`](@ref)." const ฮผ0 = 4ฯ€*(1//10)^7*H/m # exact (but gets promoted to Float64...) const ยต0 = ฮผ0 # magnetic constant -"`Unitful.ฮต0` +" Unitful.ฮต0 \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 const ฯต0 = ษ›0 # test of issue 79. -"`Unitful.Z0` +" Unitful.Z0 \nA quantity representing the impedance of free space, a constant defined as ฮผ0 ร— c. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. \nSee also: [`Unitful.ฮผ0`](@ref), [`Unitful.c`](@ref)." const Z0 = ฮผ0*c # exact, impedance of free space -"`Unitful.G` +" Unitful.G \nA quantity representing the universal gravitational constant, equal to 6.674,30 ร— 10^-11 m^3 / (kg ร— s^2) (the CODATA 2018 recommended value). \nDimension: ๐‹^3 ๐Œ^-1 ๐“^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.kg`](@ref), [`Unitful.s`](@ref)." const G = 6.674_30e-11*m^3/kg/s^2 # (15) gravitational constant -"`Unitful.gn` +" Unitful.gn \nA quantity representing the nominal acceleration due to gravity in a vacuum near the surface of the earth, defined by standard to be exactly 9.806,65 m / s^2. \nDimension: ๐‹ ๐“^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const gn = 9.80665*m/s^2 # exact, standard acceleration of gravity -"`Unitful.h` +" Unitful.h \nA quantity representing Planck's constant, defined as exactly 6.62607015 ร— 10^-34 J*s. \nDimension: ๐‹^2 ๐Œ ๐“^-1. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." const h = 6.626_070_15e-34*J*s # exact, Planck constant -"`Unitful.ฤง` -\nA quantity representing the reduced Planck constant, defined as h / (2 ฯ€). +" Unitful.ฤง +\nA quantity representing the reduced Planck constant, defined as h / 2ฯ€. \nDimension: ๐‹^2 ๐Œ ๐“^-1. \nSee also: [`Unitful.h`](@ref)." const ฤง = h/2ฯ€ # hbar -"`Unitful.ฮฆ0` +" Unitful.ฮฆ0 \nA quantity representing the superconducting magnetic flux quantum, defined as h / (2 q). \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.h`](@ref), [`Unitful.q`](@ref)." const ฮฆ0 = h/(2q) # Superconducting magnetic flux quantum -"`Unitful.me` +" Unitful.me \nA quantity representing the rest mass of an electron, equal to 9.109,383,7015 ร— 10^-31 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.๐Œ`](@ref). \nSee also: [`Unitful.kg`](@ref)." const me = 9.109_383_7015e-31*kg # (28) electron rest mass -"`Unitful.mn` +" Unitful.mn \nA quantity representing the rest mass of a neutron, equal to 1.674,927,498,04 ร— 10^-27 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.๐Œ`](@ref). \nSee also: [`Unitful.kg`](@ref)." const mn = 1.674_927_498_04e-27*kg # (95) neutron rest mass -"`Unitful.mp` +" Unitful.mp \nA quantity representing the rest mass of a proton, equal to 1.672,621,923,69 ร— 10^-27 kg (the CODATA 2018 recommended value). \nDimension: [`Unitful.๐Œ`](@ref). \nSee also: [`Unitful.kg`](@ref)." const mp = 1.672_621_923_69e-27*kg # (51) proton rest mass -"`Unitful.ฮผB` +" Unitful.ฮผB \nA quantity representing the Bohr magneton, equal to q ร— ฤง / (2 ร— me). \nDimension: ๐ˆ ๐‹^2. \nSee also: [`Unitful.q`](@ref), [`Unitful.ฤง`](@ref), [`Unitful.me`](@ref)." const ฮผB = q*ฤง/(2*me) # Bohr magneton const ยตB = ฮผB -"`Unitful.Na` +" Unitful.Na \nA quantity representing Avogadro's constant, defined as exactly 6.022,140,76 ร— 10^23 / mol. \nDimension: ๐^-1. \nSee also: [`Unitful.mol`](@ref)." const Na = 6.022_140_76e23/mol # exact, Avogadro constant -"`Unitful.k` +" Unitful.k \nA quantity representing the Boltzmann constant, defined as exactly 1.380,649 ร— 10^-23 J / K. \nDimension: ๐‹^2 ๐Œ ๐šฏ^-1 ๐“^-2. \nSee also: [`Unitful.J`](@ref), [`Unitful.K`](@ref)." const k = 1.380_649e-23*(J/K) # exact, Boltzmann constant -"`Unitful.R` +" Unitful.R \nA quantity representing the molar gas constant, defined as Na ร— k. \nDimension: ๐‹^2 ๐Œ ๐^-1 ๐šฏ^-1 ๐“^-2. \nSee also: [`Unitful.Na`](@ref), [`Unitful.k`](@ref)." const R = Na*k # molar gas constant -"`Unitful.ฯƒ` +" Unitful.ฯƒ \nA quantity representing the Stefan-Boltzmann constant, defined as ฯ€^2 ร— k^4 / (60 ร— ฤง^3 ร— c^2). \nDimension: ๐Œ ๐šฏ^-4 ๐“^-3. \nSee also: [`Unitful.k`](@ref), [`Unitful.ฤง`](@ref), [`Unitful.c`](@ref)." const ฯƒ = ฯ€^2*k^4/(60*ฤง^3*c^2) # Stefan-Boltzmann constant -"`Unitful.Rโˆž` +" Unitful.Rโˆž \nA quantity representing the Rydberg constant, equal to 1.097,373,156,8160 ร— 10^-7 / m (the CODATA 2018 recommended value). \nDimension: ๐‹^-1. \nSee also: [`Unitful.m`](@ref)." const Rโˆž = 10_973_731.568_160/m # (21) Rydberg constant -"`Unitful.u` +" Unitful.u \nThe unified atomic mass unit, or dalton, a unit of mass defined as 1/12 the mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 ร— 10^-27 kg (the CODATA 2018 recommended value). @@ -476,7 +476,7 @@ mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 ร— 10^-2 @unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false # (50) # Acceleration -"`Unitful.ge` +" Unitful.ge \nThe nominal acceleration due to gravity in a vacuum near the surface of the earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^2. \nDimension: ๐‹ ๐“^-2. @@ -485,47 +485,47 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ # CGS units -"`Unitful.Gal` +" Unitful.Gal \nThe gal, a CGS unit of acceleration, defined as 1 cm / s^2. \nDimension: ๐‹ ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)." @unit Gal "Gal" Gal 1cm/s^2 true -"`Unitful.dyn` +" Unitful.dyn \nThe dyne, a CGS unit of force, defined as 1 g ร— cm / s^2. \nDimension: ๐‹ ๐Œ ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref), [`Unitful.g`](@ref)." @unit dyn "dyn" Dyne 1g*cm/s^2 true -"`Unitful.erg` +" Unitful.erg \nThe erg, a CGS unit of energy, defined as 1 dyn ร— cm. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" @unit erg "erg" Erg 1g*cm^2/s^2 true -"`Unitful.Ba` +" Unitful.Ba \nThe barye, a CGS unit of pressure, defined as 1 dyn / cm^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" @unit Ba "Ba" Barye 1g/cm/s^2 true -"`Unitful.P` +" Unitful.P \nThe poise, a CGS unit of dynamic viscosity, defined as 1 dyn ร— s / cm^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-1. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref), [`Unitful.s`](@ref)" @unit P "P" Poise 1g/cm/s true -"`Unitful.St` +" Unitful.St \nThe stokes, a CGS unit of kinematic viscosity, defined as 1 cm^2 / s. \nDimension: ๐Œ^2 ๐“^-1. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)" @unit St "St" Stokes 1cm^2/s true -"`Unitful.Gauss` +" Unitful.Gauss \nThe gauss, a CGS unit of magnetic B-field strength, defined as 1 Mx / cm^2. \nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.Mx`](@ref)" @unit Gauss "Gauss" Gauss (1//10_000)*T true -"`Unitful.Oe` +" Unitful.Oe \nThe oersted, a CGS unit of magnetic H-field strength, defined as 1,000 ร— A / (4ฯ€ ร— m). \nDimension: ๐ˆ ๐‹^-1. \nSee also: [`Unitful.A`](@ref), [`Unitful.m`](@ref)" @unit Oe "Oe" Oersted (1_000/4ฯ€)*A/m true -"`Unitful.Mx` +" Unitful.Mx \nThe maxwell, a CGS unit of magnetic flux, defined as 1 Gauss ร— cm^2. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.Gauss`](@ref)" @@ -537,32 +537,32 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ # Length #key: Symbol Display Name Equivalent to 10^n prefixes? -"`Unitful.inch` +" Unitful.inch \nThe inch, a US customary unit of length defined as 254/10000 m. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.m`](@ref)." @unit inch "inch" Inch (254//10000)*m false -"`Unitful.mil` +" Unitful.mil \nThe mil, a US customary unit of length defined as 1/1000 inch. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.inch`](@ref)." @unit mil "mil" Mil (1//1000)*inch false -"`Unitful.ft` +" Unitful.ft \nThe foot, a US customary unit of length defined as 12 inch. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.inch`](@ref)." @unit ft "ft" Foot 12inch false -"`Unitful.yd` +" Unitful.yd \nThe yard, a US customary unit of length defined as 3 ft. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.ft`](@ref)." @unit yd "yd" Yard 3ft false -"`Unitful.mi` +" Unitful.mi \nThe mile, a US customary unit of length defined as 1760 yd. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.yd`](@ref)." @unit mi "mi" Mile 1760yd false -"`Unitful.angstrom` +" Unitful.angstrom \nThe angstrom, a metric unit of length defined as 1/10 nm. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.nm`](@ref)." @@ -571,53 +571,53 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ @doc @doc(angstrom) const ร… = โ„ซ = angstrom # Area -"`Unitful.ac` +" Unitful.ac \nThe acre, a US customary unit of area defined as 4840 yd^2. \nDimension: ๐‹^2. \nSee Also: [`Unitful.yd`](@ref)." @unit ac "ac" Acre (316160658//78125)*m^2 false # Temperatures -"`Unitful.Ra` +" Unitful.Ra \nThe rankine, a US customary unit of temperature defined as 5/9 K. \nDimension: [`Unitful.๐šฏ`](@ref). \nSee Also: [`Unitful.K`](@ref)." @unit Ra "Ra" Rankine (5//9)*K false -"`Unitful.ยฐF` +" Unitful.ยฐF \nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0 ยฐF = 459.67 Ra. \nDimension: [`Unitful.๐šฏ`](@ref). \nSee also: [`Unitful.Ra`](@ref)." @affineunit ยฐF "ยฐF" (45967//100)Ra # Masses -"`Unitful.lb` +" Unitful.lb \nThe pound-mass, a US customary unit of mass defined as exactly 0.453,592,37 kg. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.kg`](@ref)." @unit lb "lb" Pound 0.45359237kg false # is exact -"`Unitful.oz` +" Unitful.oz \nThe ounce, a US customary unit of mass defined as 1/16 lb. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lb`](@ref)." @unit oz "oz" Ounce lb//16 false -"`Unitful.slug` +" Unitful.slug \nThe slug, a US customary unit of mass defined as 1 lbf ร— s^2 / ft. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.s`](@ref), [`Unitful.ft`](@ref)." @unit slug "slug" Slug 1lb*ge*s^2/ft false -"`Unitful.dr` +" Unitful.dr \nThe dram, a US customary unit of mass defined as 1/16 oz. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.oz`](@ref)." @unit dr "dr" Dram oz//16 false -"`Unitful.gr` +" Unitful.gr \nThe grain, a US customary unit of mass defined as 1/7000 lb. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lb`](@ref)." @unit gr "gr" Grain (32//875)*dr false # Force -"`Unitful.lbf` +" Unitful.lbf \nThe pound-force, a US customary unit of force defined as 1 lb ร— ge. \nDimension: ๐‹ ๐Œ ๐“^-2. \nSee Also: [`Unitful.lb`](@ref), [`Unitful.ge`](@ref)." @@ -625,19 +625,19 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ # Energy # Use ISO 31-4 for BTU definition -"`Unitful.cal` +" Unitful.cal \nThe calorie, a unit of energy defined as exactly 4.184 J. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee Also: [`Unitful.J`](@ref)." @unit cal "cal" Calorie 4.184J true -"`Unitful.btu` +" Unitful.btu \nThe British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06 J. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee Also: [`Unitful.J`](@ref)." @unit btu "btu" BritishThermalUnit 1055.06J false # Pressure -"`Unitful.psi` +" Unitful.psi \nPounds per square inch, a US customary unit of pressure defined as 1 lbf / inch^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.inch`](@ref)." @@ -722,14 +722,14 @@ preferunits(kg) # others done in @refunit Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do for (k,v) in prefixdict sym = Symbol(v,:g) - docstring = "`Unitful."*string(sym)*"`\n\n" + docstring = " Unitful."*string(sym)*"\n\n" docstring *= "A prefixed unit, equal to 10^"*string(k-3)*" kg." docstring *= " Note that `kg`, not `g`, is the base unit." docstring *= "\n\nSee also: [`Unitful.kg`](@ref)." run = quote @doc $docstring $sym end eval(run) end - @doc "`Unitful.kg` + @doc " Unitful.kg \nThe kilogram, the SI base unit of mass. Note that `kg`, not `g`, is the base unit. \nDimension: [`Unitful.๐Œ`](@ref)." kg From bf94a7b1d32bb9d5e80da1e240ced5c7e2318ca3 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Mon, 11 Oct 2021 14:43:47 -0500 Subject: [PATCH 19/43] Add automatic documentation for everything defined by the dimension macro Also removed documentation from the pieces of log units that currently don't have any sort of automatic documentation generation system in place. --- src/user.jl | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/user.jl b/src/user.jl index ced8fd28..5c78c46d 100644 --- a/src/user.jl +++ b/src/user.jl @@ -58,14 +58,25 @@ macro dimension(symb, abbr, name) x = Expr(:quote, name) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") + name_doc = " "*string(__module__)*"."*string(name)*"{T, U}" + name_doc *= "\n\nA supertype for quantities and levels of dimension [`"*string(__module__)*"."*string(s)*"`](@ref) with a value of type `T` and units `U`." + name_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), [`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)." + unit_doc = " "*string(__module__)*"."*string(uname)*"{U}" + unit_doc *= "\n\nA supertype for units of dimension [`"*string(__module__)*"."*string(s)*"`](@ref). " + unit_doc *= "Equivalent to `Unitful.Units{U, "*string(__module__)*"."*string(s)*"}`." + unit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), [`Unitful.Units`](@ref)." + funit_doc = " "*string(__module__)*"."*string(funame)*"{U}" + funit_doc *= "\n\nA supertype for free units of dimension [`"*string(__module__)*"."*string(s)*"`](@ref). " + funit_doc *= "Equivalent to `Unitful.FreeUnits{U, "*string(__module__)*"."*string(s)*"}`." + funit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), [`Unitful.FreeUnits`](@ref)." esc(quote $Unitful.abbr(::$Dimension{$x}) = $abbr Base.@__doc__ const global $s = $Dimensions{($Dimension{$x}(1),)}() - Base.@__doc__ const global ($name){T,U} = Union{ + @doc $name_doc const global ($name){T,U} = Union{ $Quantity{T,$s,U}, $Level{L,S,$Quantity{T,$s,U}} where {L,S}} - const global ($uname){U} = $Units{U,$s} - const global ($funame){U} = $FreeUnits{U,$s} + @doc $unit_doc const global ($uname){U} = $Units{U,$s} + @doc $funit_doc const global ($funame){U} = $FreeUnits{U,$s} $s end) end @@ -405,7 +416,7 @@ macro logscale(symb,abbr,name,base,prefactor,irp) const global $(esc(Symbol(symb,"_rp"))) = MixedUnits{Gain{$(esc(name)), :rp}}() const global $(esc(Symbol(symb,"_p"))) = MixedUnits{Gain{$(esc(name)), :p}}() - Base.@__doc__ macro $(esc(symb))(::Union{Real,Symbol}) + macro $(esc(symb))(::Union{Real,Symbol}) throw(ArgumentError(join(["usage: `@", $(String(symb)), " (a)/(b)`"]))) end @@ -434,7 +445,7 @@ macro logscale(symb,abbr,name,base,prefactor,irp) return Level{$(esc(name)), den}(num) end - Base.@__doc__ function (::$(esc(:typeof))($(esc(symb))))(num::Number, den::Number, irp::Bool) + function (::$(esc(:typeof))($(esc(symb))))(num::Number, den::Number, irp::Bool) dimension(num) != dimension(den) && throw(DimensionError(num,den)) dimension(num) != NoDims && throw(ArgumentError(string("when passing a final Bool argument, ", From a0f37eafb02bbe8315f22dbff2ced3b6192a8244 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Mon, 11 Oct 2021 14:49:19 -0500 Subject: [PATCH 20/43] Fix documentation issues with two different symbols for vacuum permittivity constant. --- src/pkgdefaults.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index d2c69ebd..d1d623e4 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -378,7 +378,7 @@ const ยต0 = ฮผ0 # magnetic constant \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 -const ฯต0 = ษ›0 # test of issue 79. +@doc @doc(ษ›0) const ฯต0 = ษ›0 # test of issue 79. " Unitful.Z0 \nA quantity representing the impedance of free space, a constant defined as ฮผ0 ร— c. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. From 17d3f42b3351387670a6baf07b52064bbe3582cc Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Mon, 11 Oct 2021 14:53:07 -0500 Subject: [PATCH 21/43] Minor formatting fixes --- src/pkgdefaults.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index d1d623e4..a5fc6bdc 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -398,7 +398,7 @@ near the surface of the earth, defined by standard to be exactly 9.806,65 m / s^ const gn = 9.80665*m/s^2 # exact, standard acceleration of gravity " Unitful.h \nA quantity representing Planck's constant, defined as exactly -6.62607015 ร— 10^-34 J*s. +6.62607015 ร— 10^-34 J ร— s. \nDimension: ๐‹^2 ๐Œ ๐“^-1. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." const h = 6.626_070_15e-34*J*s # exact, Planck constant @@ -538,9 +538,9 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ # Length #key: Symbol Display Name Equivalent to 10^n prefixes? " Unitful.inch -\nThe inch, a US customary unit of length defined as 254/10000 m. +\nThe inch, a US customary unit of length defined as 2.54 cm. \nDimension: [`Unitful.๐‹`](@ref). -\nSee Also: [`Unitful.m`](@ref)." +\nSee Also: [`Unitful.cm`](@ref)." @unit inch "inch" Inch (254//10000)*m false " Unitful.mil \nThe mil, a US customary unit of length defined as 1/1000 inch. From bf36719d793821f17b598b4db92a090a471ab251 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Mon, 11 Oct 2021 14:56:09 -0500 Subject: [PATCH 22/43] Use block quotes for prefixed units' doc strings --- src/user.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user.jl b/src/user.jl index 5c78c46d..b993471c 100644 --- a/src/user.jl +++ b/src/user.jl @@ -250,7 +250,7 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor) s = Symbol(v,symb) u = :($Unit{$n, $user_dimension}($k,1//1)) isbase = k==0 - docstring1 = "`"*string(__module__)*"."*string(s)*"`\n\nA prefixed unit, equal to 10^"*string(k)*" "*string(symb)*"." + docstring1 = " "*string(__module__)*"."*string(s)*"\n\nA prefixed unit, equal to 10^"*string(k)*" "*string(symb)*"." docstring1 *= "\n\nSee also: [`"*string(__module__)*"."*string(symb)*"`](@ref)." ea = quote $(basefactors_expr(__module__, n, basefactor)) From f2b48963cf405cddab36033d3b0f444eedf02662 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Tue, 12 Oct 2021 07:54:37 -0600 Subject: [PATCH 23/43] Update src/types.jl Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/types.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.jl b/src/types.jl index 268ee757..bfff4d46 100644 --- a/src/types.jl +++ b/src/types.jl @@ -27,7 +27,7 @@ end Instances of this object represent dimensions, possibly combinations thereof. """ struct Dimensions{N} <: Unitlike end -"`Unitful.NoDims` +" Unitful.NoDims \nA dimension representing quantities without dimensions." const NoDims = Dimensions{()}() From e74f6c24276b44882c7ace64a8fee0b8077f3a20 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Tue, 12 Oct 2021 13:47:59 -0500 Subject: [PATCH 24/43] Make automatic documentation optional Also (optionally) generate automatic documentation for derived dimensions. --- src/pkgdefaults.jl | 238 ++++++++++++++++++++++----------------------- src/user.jl | 77 +++++++++++---- 2 files changed, 179 insertions(+), 136 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index a5fc6bdc..425e2eac 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -4,65 +4,65 @@ # dimensions from units, and also helps prevent common namespace collisions. " Unitful.๐‹ \nA dimension representing length." -@dimension ๐‹ "๐‹" Length +@dimension ๐‹ "๐‹" Length true " Unitful.๐Œ \nA dimension representing mass." -@dimension ๐Œ "๐Œ" Mass +@dimension ๐Œ "๐Œ" Mass true " Unitful.๐“ \nA dimension representing time." -@dimension ๐“ "๐“" Time +@dimension ๐“ "๐“" Time true " Unitful.๐ˆ \nA dimension representing electric current." -@dimension ๐ˆ "๐ˆ" Current +@dimension ๐ˆ "๐ˆ" Current true " Unitful.๐šฏ \nA dimension representing thermodynamic temperature." -@dimension ๐šฏ "๐šฏ" Temperature # This one is \bfTheta +@dimension ๐šฏ "๐šฏ" Temperature true # This one is \bfTheta " Unitful.๐‰ \nA dimension representing luminous intensity." -@dimension ๐‰ "๐‰" Luminosity +@dimension ๐‰ "๐‰" Luminosity true " Unitful.๐ \nA dimension representing amount of substance." -@dimension ๐ "๐" Amount +@dimension ๐ "๐" Amount true const RelativeScaleTemperature = Quantity{T, ๐šฏ, <:AffineUnits} where T const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T # Define derived dimensions. -@derived_dimension Area ๐‹^2 -@derived_dimension Volume ๐‹^3 -@derived_dimension Density ๐Œ/๐‹^3 -@derived_dimension Frequency inv(๐“) -@derived_dimension Velocity ๐‹/๐“ -@derived_dimension Acceleration ๐‹/๐“^2 -@derived_dimension Force ๐Œ*๐‹/๐“^2 -@derived_dimension Pressure ๐Œ*๐‹^-1*๐“^-2 -@derived_dimension Energy ๐Œ*๐‹^2/๐“^2 -@derived_dimension Momentum ๐Œ*๐‹/๐“ -@derived_dimension Power ๐‹^2*๐Œ*๐“^-3 -@derived_dimension Charge ๐ˆ*๐“ -@derived_dimension Voltage ๐ˆ^-1*๐‹^2*๐Œ*๐“^-3 -@derived_dimension ElectricalResistance ๐ˆ^-2*๐‹^2*๐Œ*๐“^-3 -@derived_dimension ElectricalResistivity ๐ˆ^-2*๐‹^3*๐Œ*๐“^-3 -@derived_dimension ElectricalConductance ๐ˆ^2*๐‹^-2*๐Œ^-1*๐“^3 -@derived_dimension ElectricalConductivity ๐ˆ^2*๐‹^-3*๐Œ^-1*๐“^3 -@derived_dimension Capacitance ๐ˆ^2*๐‹^-2*๐Œ^-1*๐“^4 -@derived_dimension Inductance ๐ˆ^-2*๐‹^2*๐Œ*๐“^-2 -@derived_dimension MagneticFlux ๐ˆ^-1*๐‹^2*๐Œ*๐“^-2 -@derived_dimension DField ๐ˆ*๐“/๐‹^2 -@derived_dimension EField ๐‹*๐Œ*๐“^-3*๐ˆ^-1 -@derived_dimension HField ๐ˆ/๐‹ -@derived_dimension BField ๐ˆ^-1*๐Œ*๐“^-2 -@derived_dimension Action ๐‹^2*๐Œ*๐“^-1 -@derived_dimension DynamicViscosity ๐Œ*๐‹^-1*๐“^-1 -@derived_dimension KinematicViscosity ๐‹^2*๐“^-1 -@derived_dimension Wavenumber inv(๐‹) -@derived_dimension ElectricDipoleMoment ๐‹*๐“*๐ˆ -@derived_dimension ElectricQuadrupoleMoment ๐‹^2*๐“*๐ˆ -@derived_dimension MagneticDipoleMoment ๐‹^2*๐ˆ -@derived_dimension Molarity ๐/๐‹^3 -@derived_dimension Molality ๐/๐Œ -@derived_dimension MassFlow ๐Œ/๐“ -@derived_dimension MolarFlow ๐/๐“ -@derived_dimension VolumeFlow ๐‹^3/๐“ +@derived_dimension Area ๐‹^2 true +@derived_dimension Volume ๐‹^3 true +@derived_dimension Density ๐Œ/๐‹^3 true +@derived_dimension Frequency inv(๐“) true +@derived_dimension Velocity ๐‹/๐“ true +@derived_dimension Acceleration ๐‹/๐“^2 true +@derived_dimension Force ๐Œ*๐‹/๐“^2 true +@derived_dimension Pressure ๐Œ*๐‹^-1*๐“^-2 true +@derived_dimension Energy ๐Œ*๐‹^2/๐“^2 true +@derived_dimension Momentum ๐Œ*๐‹/๐“ true +@derived_dimension Power ๐‹^2*๐Œ*๐“^-3 true +@derived_dimension Charge ๐ˆ*๐“ true +@derived_dimension Voltage ๐ˆ^-1*๐‹^2*๐Œ*๐“^-3 true +@derived_dimension ElectricalResistance ๐ˆ^-2*๐‹^2*๐Œ*๐“^-3 true +@derived_dimension ElectricalResistivity ๐ˆ^-2*๐‹^3*๐Œ*๐“^-3 true +@derived_dimension ElectricalConductance ๐ˆ^2*๐‹^-2*๐Œ^-1*๐“^3 true +@derived_dimension ElectricalConductivity ๐ˆ^2*๐‹^-3*๐Œ^-1*๐“^3 true +@derived_dimension Capacitance ๐ˆ^2*๐‹^-2*๐Œ^-1*๐“^4 true +@derived_dimension Inductance ๐ˆ^-2*๐‹^2*๐Œ*๐“^-2 true +@derived_dimension MagneticFlux ๐ˆ^-1*๐‹^2*๐Œ*๐“^-2 true +@derived_dimension DField ๐ˆ*๐“/๐‹^2 true +@derived_dimension EField ๐‹*๐Œ*๐“^-3*๐ˆ^-1 true +@derived_dimension HField ๐ˆ/๐‹ true +@derived_dimension BField ๐ˆ^-1*๐Œ*๐“^-2 true +@derived_dimension Action ๐‹^2*๐Œ*๐“^-1 true +@derived_dimension DynamicViscosity ๐Œ*๐‹^-1*๐“^-1 true +@derived_dimension KinematicViscosity ๐‹^2*๐“^-1 true +@derived_dimension Wavenumber inv(๐‹) true +@derived_dimension ElectricDipoleMoment ๐‹*๐“*๐ˆ true +@derived_dimension ElectricQuadrupoleMoment ๐‹^2*๐“*๐ˆ true +@derived_dimension MagneticDipoleMoment ๐‹^2*๐ˆ true +@derived_dimension Molarity ๐/๐‹^3 true +@derived_dimension Molality ๐/๐Œ true +@derived_dimension MassFlow ๐Œ/๐“ true +@derived_dimension MolarFlow ๐/๐“ true +@derived_dimension VolumeFlow ๐‹^3/๐“ true # Define base units. This is not to imply g is the base SI unit instead of kg. # See the documentation for further details. @@ -70,43 +70,43 @@ const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T " Unitful.m \nThe meter, the SI base unit of length. \nDimension: [`Unitful.๐‹`](@ref)." -@refunit m "m" Meter ๐‹ true +@refunit m "m" Meter ๐‹ true true " Unitful.s \nThe second, the SI base unit of time. \nDimension: [`Unitful.๐“`](@ref)." -@refunit s "s" Second ๐“ true +@refunit s "s" Second ๐“ true true " Unitful.A \nThe ampere, the SI base unit of electric current. \nDimension: [`Unitful.๐ˆ`](@ref)." -@refunit A "A" Ampere ๐ˆ true +@refunit A "A" Ampere ๐ˆ true true " Unitful.K \nThe kelvin, the SI base unit of thermodynamic temperature. \nDimension: [`Unitful.๐šฏ`](@ref)." -@refunit K "K" Kelvin ๐šฏ true +@refunit K "K" Kelvin ๐šฏ true true " Unitful.cd \nThe candela, the SI base unit of luminous intensity. \nDimension: [`Unitful.๐‰`](@ref)." -@refunit cd "cd" Candela ๐‰ true +@refunit cd "cd" Candela ๐‰ true true # the docs for all gram-based units are defined later, to ensure kg is the base unit. @refunit g "g" Gram ๐Œ true " Unitful.mol \nThe mole, the SI base unit for amount of substance. \nDimension: [`Unitful.๐`](@ref)." -@refunit mol "mol" Mole ๐ true +@refunit mol "mol" Mole ๐ true true # Angles and solid angles " Unitful.sr \nThe steradian, a unit of spherical angle. There are 4ฯ€ sr in a sphere. \nDimension: [`Unitful.NoDims`](@ref)." -@unit sr "sr" Steradian 1 true +@unit sr "sr" Steradian 1 true true " Unitful.rad \nThe radian, a unit of angle. There are 2ฯ€ rad in a circle. \nDimension: [`Unitful.NoDims`](@ref)." -@unit rad "rad" Radian 1 true +@unit rad "rad" Radian 1 true true " Unitful.ยฐ \nThe degree, a unit of angle. There are 360ยฐ in a circle. \nDimension: [`Unitful.NoDims`](@ref)." -@unit ยฐ "ยฐ" Degree pi/180 false +@unit ยฐ "ยฐ" Degree pi/180 false true # For numerical accuracy, specific to the degree import Base: sind, cosd, tand, secd, cscd, cotd for (_x,_y) in ((:sin,:sind), (:cos,:cosd), (:tan,:tand), @@ -125,111 +125,111 @@ rad2deg(r::Quantity{T, NoDims, typeof(rad)}) where {T} = rad2deg(ustrip(rad, r)) \nThe hertz, an SI unit of frequency, defined as 1 s^-1. \nDimension: ๐“^-1. \nSee also: [`Unitful.s`](@ref)." -@unit Hz "Hz" Hertz 1/s true +@unit Hz "Hz" Hertz 1/s true true " Unitful.N \nThe newton, an SI unit of force, defined as 1 kg ร— m / s^2. \nDimension: ๐‹ ๐Œ ๐“^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit N "N" Newton 1kg*m/s^2 true +@unit N "N" Newton 1kg*m/s^2 true true " Unitful.Pa \nThe pascal, an SI unit of pressure, defined as 1 N / m^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." -@unit Pa "Pa" Pascal 1N/m^2 true +@unit Pa "Pa" Pascal 1N/m^2 true true " Unitful.J \nThe joule, an SI unit of energy, defined as 1 N ร— m. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee also: [`Unitful.N`](@ref), [`Unitful.m`](@ref)." -@unit J "J" Joule 1N*m true +@unit J "J" Joule 1N*m true true " Unitful.W \nThe watt, an SI unit of power, defined as 1 J / s. \nDimension: ๐‹^2 ๐Œ ๐“^-3. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." -@unit W "W" Watt 1J/s true +@unit W "W" Watt 1J/s true true " Unitful.C \nThe coulomb, an SI unit of electric charge, defined as 1 A ร— s. \nDimension: ๐ˆ ๐“. \nSee also: [`Unitful.A`](@ref), [`Unitful.s`](@ref)." -@unit C "C" Coulomb 1A*s true +@unit C "C" Coulomb 1A*s true true " Unitful.V \nThe volt, an SI unit of electric potential, defined as 1 W / A. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-3. \nSee also: [`Unitful.W`](@ref), [`Unitful.A`](@ref)" -@unit V "V" Volt 1W/A true +@unit V "V" Volt 1W/A true true " Unitful.โ„ฆ \nThe ohm, an SI unit of electrical resistance, defined as 1 V / A. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-3. \nSee also: [`Unitful.V`](@ref), [`Unitful.A`](@ref)." -@unit ฮฉ "ฮฉ" Ohm 1V/A true +@unit ฮฉ "ฮฉ" Ohm 1V/A true true " Unitful.S \nThe siemens, an SI unit of electrical conductance, defined as 1 ฮฉ^-1. \nDimension: ๐ˆ^2 ๐“^3 ๐‹^-2 ๐Œ^-1. \nSee also: [`Unitful.ฮฉ`](@ref)" -@unit S "S" Siemens 1/ฮฉ true +@unit S "S" Siemens 1/ฮฉ true true " Unitful.F \nThe farad, an SI unit of electrical capacitance, defined as 1 s^4 ร— A^2 / (kg ร— m^2). \nDimension: ๐ˆ^2 ๐“^4 ๐‹^-2 ๐Œ^-1. \nSee also: [`Unitful.s`](@ref), [`Unitful.A`](@ref), [`Unitful.kg`](@ref), [`Unitful.m`](@ref)." -@unit F "F" Farad 1s^4*A^2/(kg*m^2) true +@unit F "F" Farad 1s^4*A^2/(kg*m^2) true true " Unitful.H \nThe henry, an SI unit of electrical inductance, defined as 1 J / A^2. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-2 ๐“^-2. \nSee also: [`Unitful.J`](@ref), [`Unitful.A`](@ref)." -@unit H "H" Henry 1J/(A^2) true +@unit H "H" Henry 1J/(A^2) true true " Unitful.T \nThe tesla, an SI unit of magnetic B-field strength, defined as 1 kg / (A ร— s^2). \nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." -@unit T "T" Tesla 1kg/(A*s^2) true +@unit T "T" Tesla 1kg/(A*s^2) true true " Unitful.Wb \nThe weber, an SI unit of magnetic flux, defined as 1 kg ร— m^2 / (A ร— s^2). \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.kg`](@ref), [`Unitful.m`](@ref), [`Unitful.A`](@ref), [`Unitful.s`](@ref)." -@unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true +@unit Wb "Wb" Weber 1kg*m^2/(A*s^2) true true " Unitful.lm \nThe lumen, an SI unit of luminous flux, defined as 1 cd ร— sr. \nDimension: [`Unitful.๐‰`](@ref). \nSee also: [`Unitful.cd`](@ref), [`Unitful.sr`](@ref)." -@unit lm "lm" Lumen 1cd*sr true +@unit lm "lm" Lumen 1cd*sr true true " Unitful.lx \nThe lux, an SI unit of illuminance, defined as 1 lm / m^2. \nDimension: ๐‰ ๐‹^-2. \nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." -@unit lx "lx" Lux 1lm/m^2 true +@unit lx "lx" Lux 1lm/m^2 true true " Unitful.Bq \nThe becquerel, an SI unit of radioactivity, defined as 1 nuclear decay per s. \nDimension: ๐“^-1. \nSee also: [`Unitful.s`](@ref)." -@unit Bq "Bq" Becquerel 1/s true +@unit Bq "Bq" Becquerel 1/s true true " Unitful.Gy \nThe gray, an SI unit of ionizing radiation dose, defined as the absorbtion of 1 J per kg of matter. \nDimension: ๐‹^2 ๐“^-2. \nSee also: [`Unitful.lm`](@ref), [`Unitful.m`](@ref)." -@unit Gy "Gy" Gray 1J/kg true +@unit Gy "Gy" Gray 1J/kg true true " Unitful.Sv \nThe sievert, an SI unit of the biological effect of an ionizing radiation dose. Defined as the health effect of 1 Gy of radiation, scaled by a quality factor. \nDimension: ๐‹^2 ๐“^-2. \nSee also: [`Unitful.Gy`](@ref)." -@unit Sv "Sv" Sievert 1J/kg true +@unit Sv "Sv" Sievert 1J/kg true true " Unitful.kat \nThe katal, an SI unit of catalytic activity, defined as 1 mol of catalyzed substrate per s. \nDimension: ๐ ๐“^-1. \nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." -@unit kat "kat" Katal 1mol/s true +@unit kat "kat" Katal 1mol/s true true " Unitful.percent \nPercent, a unit meaning parts per hundred. \nDimension: [`Unitful.NoDims`](@ref)." -@unit percent "%" Percent 1//100 false +@unit percent "%" Percent 1//100 false true " Unitful.permille \nPermille, a unit meaning parts per thousand. \nDimension: [`Unitful.NoDims`](@ref)." -@unit permille "โ€ฐ" Permille 1//1000 false +@unit permille "โ€ฐ" Permille 1//1000 false true " Unitful.pertenthousand \nPermyriad, a unit meaning parts per ten thousand. \nDimension: [`Unitful.NoDims`](@ref)." -@unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false +@unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false true # Temperature " Unitful.ยฐC @@ -244,37 +244,37 @@ substrate per s. to avoid confusion with the Julia function `min`. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.s`](@ref)." -@unit minute "minute" Minute 60s false +@unit minute "minute" Minute 60s false true " Unitful.hr \nThe hour, a unit of time defined as 60 minutes. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.minute`](@ref)." -@unit hr "hr" Hour 3600s false +@unit hr "hr" Hour 3600s false true " Unitful.d \nThe day, a unit of time defined as 24 hr. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.hr`](@ref)." -@unit d "d" Day 86400s false +@unit d "d" Day 86400s false true " Unitful.wk \nThe week, a unit of time, defined as 7 d. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.d`](@ref)." -@unit wk "wk" Week 604800s false +@unit wk "wk" Week 604800s false true " Unitful.yr \nThe year, a unit of time, defined as 365.25 d. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.hr`](@ref)." -@unit yr "yr" Year 31557600s true +@unit yr "yr" Year 31557600s true true " Unitful.rps \nRevolutions per second, a unit of rotational speed, defined as 2ฯ€ rad / s. \nDimension: ๐“^-1. \nSee Also: [`Unitful.rad`](@ref), [`Unitful.s`](@ref)." -@unit rps "rps" RevolutionsPerSecond 2ฯ€*rad/s false +@unit rps "rps" RevolutionsPerSecond 2ฯ€*rad/s false true " Unitful.rpm \nRevolutions per minute, a unit of rotational speed, defined as 2ฯ€ rad / minute. \nDimension: ๐“^-1. \nSee Also: [`Unitful.minute`](@ref), [`Unitful.rad`](@ref)." -@unit rpm "rpm" RevolutionsPerMinute 2ฯ€*rad/minute false +@unit rpm "rpm" RevolutionsPerMinute 2ฯ€*rad/minute false true # Area # The hectare is used more frequently than any other power-of-ten of an are. @@ -282,7 +282,7 @@ to avoid confusion with the Julia function `min`. \nThe are, a metric unit of area, defined as 100 m^2. \nDimension: ๐‹^2. \nSee Also: [`Unitful.m`](@ref)." -@unit a "a" Are 100m^2 false +@unit a "a" Are 100m^2 false true " Unitful.ha \nThe hectare, a metric unit of area, defined as 100 a. \nDimension: ๐‹^2. @@ -292,7 +292,7 @@ const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, ๐‹^2}(2, 1//1),), ๐‹^2}() \nThe barn, a metric unit of area, defined as 100 fm^2. \nDimension: ๐‹^2. \nSee Also: [`Unitful.fm`](@ref)." -@unit b "b" Barn 100fm^2 true +@unit b "b" Barn 100fm^2 true true # Volume # `l` is also an acceptable symbol for liters @@ -300,7 +300,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 +@unit L "L" Liter m^3//1000 true 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)))) @@ -316,7 +316,7 @@ end solute per L of solution. \nDimension: ๐ ๐‹^-3. \nSee Also: [`Unitful.L`](@ref), [`Unitful.mol`](@ref)." -@unit M "M" Molar 1mol/L true +@unit M "M" Molar 1mol/L true true # Energy " Unitful.q @@ -330,29 +330,29 @@ const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... \nThe electron-volt, a unit of energy, defined as q*V. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee also: [`Unitful.q`](@ref), [`Unitful.V`](@ref)." -@unit eV "eV" eV q*V true +@unit eV "eV" eV q*V true true # For convenience " Unitful.Hz2ฯ€ \nA unit for convenience in angular frequency, equal to 2ฯ€ Hz. \nDimension: ๐“^-1. \nSee also: [`Unitful.Hz`](@ref)." -@unit Hz2ฯ€ "Hz2ฯ€" AngHertz 2ฯ€/s true +@unit Hz2ฯ€ "Hz2ฯ€" AngHertz 2ฯ€/s true true " Unitful.bar \nThe bar, a metric unit of pressure, defined as 100 kPa. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.kPa`](@ref)." -@unit bar "bar" Bar 100000Pa true +@unit bar "bar" Bar 100000Pa true true " Unitful.atm \nThe standard atmosphere, a unit of pressure, defined as 101,325 Pa. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.Pa`](@ref)." -@unit atm "atm" Atmosphere 101325Pa false +@unit atm "atm" Atmosphere 101325Pa false true " Unitful.Torr \nThe torr, a unit of pressure, defined as 1/760 atm. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.atm`](@ref)." -@unit Torr "Torr" Torr 101325Pa//760 true +@unit Torr "Torr" Torr 101325Pa//760 true true # Constants (2018 CODATA values) (uncertainties in final digits) " Unitful.c0 @@ -366,7 +366,7 @@ const c0 = 299_792_458*m/s # exact 2.997,924,58 ร— 10^8 m/s. \nDimension: ๐‹ ๐“^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit c "c" SpeedOfLight 1c0 false +@unit c "c" SpeedOfLight 1c0 false true " Unitful.ฮผ0 \nA quantity representing the vacuum permeability constant, defined as 4ฯ€ ร— 10^-7 H / m. \nDimension: ๐‹ ๐Œ ๐ˆ^-2 ๐“^-2. @@ -473,7 +473,7 @@ mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 ร— 10^-2 (the CODATA 2018 recommended value). \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.kg`](@ref)." -@unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false # (50) +@unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false true # (50) # Acceleration " Unitful.ge @@ -481,7 +481,7 @@ mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 ร— 10^-2 earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^2. \nDimension: ๐‹ ๐“^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit ge "ge" EarthGravity gn false +@unit ge "ge" EarthGravity gn false true # CGS units @@ -489,47 +489,47 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe gal, a CGS unit of acceleration, defined as 1 cm / s^2. \nDimension: ๐‹ ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)." -@unit Gal "Gal" Gal 1cm/s^2 true +@unit Gal "Gal" Gal 1cm/s^2 true true " Unitful.dyn \nThe dyne, a CGS unit of force, defined as 1 g ร— cm / s^2. \nDimension: ๐‹ ๐Œ ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref), [`Unitful.g`](@ref)." -@unit dyn "dyn" Dyne 1g*cm/s^2 true +@unit dyn "dyn" Dyne 1g*cm/s^2 true true " Unitful.erg \nThe erg, a CGS unit of energy, defined as 1 dyn ร— cm. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" -@unit erg "erg" Erg 1g*cm^2/s^2 true +@unit erg "erg" Erg 1g*cm^2/s^2 true true " Unitful.Ba \nThe barye, a CGS unit of pressure, defined as 1 dyn / cm^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref)" -@unit Ba "Ba" Barye 1g/cm/s^2 true +@unit Ba "Ba" Barye 1g/cm/s^2 true true " Unitful.P \nThe poise, a CGS unit of dynamic viscosity, defined as 1 dyn ร— s / cm^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-1. \nSee also: [`Unitful.cm`](@ref), [`Unitful.dyn`](@ref), [`Unitful.s`](@ref)" -@unit P "P" Poise 1g/cm/s true +@unit P "P" Poise 1g/cm/s true true " Unitful.St \nThe stokes, a CGS unit of kinematic viscosity, defined as 1 cm^2 / s. \nDimension: ๐Œ^2 ๐“^-1. \nSee also: [`Unitful.cm`](@ref), [`Unitful.s`](@ref)" -@unit St "St" Stokes 1cm^2/s true +@unit St "St" Stokes 1cm^2/s true true " Unitful.Gauss \nThe gauss, a CGS unit of magnetic B-field strength, defined as 1 Mx / cm^2. \nDimension: ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.Mx`](@ref)" -@unit Gauss "Gauss" Gauss (1//10_000)*T true +@unit Gauss "Gauss" Gauss (1//10_000)*T true true " Unitful.Oe \nThe oersted, a CGS unit of magnetic H-field strength, defined as 1,000 ร— A / (4ฯ€ ร— m). \nDimension: ๐ˆ ๐‹^-1. \nSee also: [`Unitful.A`](@ref), [`Unitful.m`](@ref)" -@unit Oe "Oe" Oersted (1_000/4ฯ€)*A/m true +@unit Oe "Oe" Oersted (1_000/4ฯ€)*A/m true true " Unitful.Mx \nThe maxwell, a CGS unit of magnetic flux, defined as 1 Gauss ร— cm^2. \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.cm`](@ref), [`Unitful.Gauss`](@ref)" -@unit Mx "Mx" Maxwell (1//100_000_000)*Wb true +@unit Mx "Mx" Maxwell (1//100_000_000)*Wb true true ######### @@ -541,32 +541,32 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe inch, a US customary unit of length defined as 2.54 cm. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.cm`](@ref)." -@unit inch "inch" Inch (254//10000)*m false +@unit inch "inch" Inch (254//10000)*m false true " Unitful.mil \nThe mil, a US customary unit of length defined as 1/1000 inch. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.inch`](@ref)." -@unit mil "mil" Mil (1//1000)*inch false +@unit mil "mil" Mil (1//1000)*inch false true " Unitful.ft \nThe foot, a US customary unit of length defined as 12 inch. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.inch`](@ref)." -@unit ft "ft" Foot 12inch false +@unit ft "ft" Foot 12inch false true " Unitful.yd \nThe yard, a US customary unit of length defined as 3 ft. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.ft`](@ref)." -@unit yd "yd" Yard 3ft false +@unit yd "yd" Yard 3ft false true " Unitful.mi \nThe mile, a US customary unit of length defined as 1760 yd. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.yd`](@ref)." -@unit mi "mi" Mile 1760yd false +@unit mi "mi" Mile 1760yd false true " Unitful.angstrom \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 +@unit angstrom "โ„ซ" Angstrom (1//10)*nm false true # U+00c5 (opt-shift-A on macOS) and U+212b ('\Angstrom' in REPL) look identical: @doc @doc(angstrom) const ร… = โ„ซ = angstrom @@ -575,14 +575,14 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe acre, a US customary unit of area defined as 4840 yd^2. \nDimension: ๐‹^2. \nSee Also: [`Unitful.yd`](@ref)." -@unit ac "ac" Acre (316160658//78125)*m^2 false +@unit ac "ac" Acre (316160658//78125)*m^2 false true # Temperatures " Unitful.Ra \nThe rankine, a US customary unit of temperature defined as 5/9 K. \nDimension: [`Unitful.๐šฏ`](@ref). \nSee Also: [`Unitful.K`](@ref)." -@unit Ra "Ra" Rankine (5//9)*K false +@unit Ra "Ra" Rankine (5//9)*K false true " Unitful.ยฐF \nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0 ยฐF = 459.67 Ra. \nDimension: [`Unitful.๐šฏ`](@ref). @@ -594,34 +594,34 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe pound-mass, a US customary unit of mass defined as exactly 0.453,592,37 kg. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.kg`](@ref)." -@unit lb "lb" Pound 0.45359237kg false # is exact +@unit lb "lb" Pound 0.45359237kg false true # is exact " Unitful.oz \nThe ounce, a US customary unit of mass defined as 1/16 lb. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lb`](@ref)." -@unit oz "oz" Ounce lb//16 false +@unit oz "oz" Ounce lb//16 false true " Unitful.slug \nThe slug, a US customary unit of mass defined as 1 lbf ร— s^2 / ft. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.s`](@ref), [`Unitful.ft`](@ref)." -@unit slug "slug" Slug 1lb*ge*s^2/ft false +@unit slug "slug" Slug 1lb*ge*s^2/ft false true " Unitful.dr \nThe dram, a US customary unit of mass defined as 1/16 oz. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.oz`](@ref)." -@unit dr "dr" Dram oz//16 false +@unit dr "dr" Dram oz//16 false true " Unitful.gr \nThe grain, a US customary unit of mass defined as 1/7000 lb. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lb`](@ref)." -@unit gr "gr" Grain (32//875)*dr false +@unit gr "gr" Grain (32//875)*dr false true # Force " Unitful.lbf \nThe pound-force, a US customary unit of force defined as 1 lb ร— ge. \nDimension: ๐‹ ๐Œ ๐“^-2. \nSee Also: [`Unitful.lb`](@ref), [`Unitful.ge`](@ref)." -@unit lbf "lbf" PoundsForce 1lb*ge false +@unit lbf "lbf" PoundsForce 1lb*ge false true # Energy # Use ISO 31-4 for BTU definition @@ -629,19 +629,19 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe calorie, a unit of energy defined as exactly 4.184 J. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee Also: [`Unitful.J`](@ref)." -@unit cal "cal" Calorie 4.184J true +@unit cal "cal" Calorie 4.184J true true " Unitful.btu \nThe British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06 J. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee Also: [`Unitful.J`](@ref)." -@unit btu "btu" BritishThermalUnit 1055.06J false +@unit btu "btu" BritishThermalUnit 1055.06J false true # Pressure " Unitful.psi \nPounds per square inch, a US customary unit of pressure defined as 1 lbf / inch^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.inch`](@ref)." -@unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false +@unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false true ######### # Logarithmic scales and units diff --git a/src/user.jl b/src/user.jl index b993471c..39ac734f 100644 --- a/src/user.jl +++ b/src/user.jl @@ -27,6 +27,7 @@ end """ @dimension(symb, abbr, name) + @dimension(symb, abbr, name, autodocs) Creates new dimensions. `name` will be used like an identifier in the type parameter for a [`Unitful.Dimension`](@ref) object. `symb` will be a symbol defined in the namespace from which this macro is called that is bound to a @@ -43,6 +44,7 @@ of the newly defined dimension. The type alias for quantities or levels is simpl `name`, and the type alias for units is given by `name*"Units"`, e.g. `LengthUnits`. Note that there is also `LengthFreeUnits`, for example, which is an alias for dispatching on `FreeUnits` with length dimensions. The aliases are not exported. +If `autodocs == true`, documentation will be automatically generated for these aliases. Finally, if you define new dimensions with [`@dimension`](@ref) you will need to specify a preferred unit for that dimension with [`Unitful.preferunits`](@ref), @@ -53,7 +55,7 @@ Returns the `Dimensions` object to which `symb` is bound. Usage example from `src/pkgdefaults.jl`: `@dimension ๐‹ "๐‹" Length` """ -macro dimension(symb, abbr, name) +macro dimension(symb, abbr, name, autodocs) s = Symbol(symb) x = Expr(:quote, name) uname = Symbol(name,"Units") @@ -72,20 +74,30 @@ macro dimension(symb, abbr, name) esc(quote $Unitful.abbr(::$Dimension{$x}) = $abbr Base.@__doc__ const global $s = $Dimensions{($Dimension{$x}(1),)}() - @doc $name_doc const global ($name){T,U} = Union{ + const global ($name){T,U} = Union{ $Quantity{T,$s,U}, $Level{L,S,$Quantity{T,$s,U}} where {L,S}} - @doc $unit_doc const global ($uname){U} = $Units{U,$s} - @doc $funit_doc const global ($funame){U} = $FreeUnits{U,$s} + const global ($uname){U} = $Units{U,$s} + const global ($funame){U} = $FreeUnits{U,$s} + if ($autodocs) + @doc $name_doc ($name) + @doc $unit_doc ($uname) + @doc $funit_doc ($funame) + end $s end) end +macro dimension(symb, abbr, name) + esc(:(@dimension($symb,$abbr,$name,false))) +end """ @derived_dimension(name, dims) + @derived_dimension(name, dims, autodocs) Creates type aliases to allow dispatch on [`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref), and [`Unitful.Units`](@ref) objects of a derived dimension, like area, which is just length squared. The type aliases are not exported. +If `autodocs == true`, documentation will be automatically generated for these aliases. `dims` is a [`Unitful.Dimensions`](@ref) object. @@ -96,22 +108,42 @@ Usage examples: - `@derived_dimension Area ๐‹^2` gives `Area` and `AreaUnit` type aliases - `@derived_dimension Speed ๐‹/๐“` gives `Speed` and `SpeedUnit` type aliases """ -macro derived_dimension(name, dims) +macro derived_dimension(name, dims, autodocs) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") + name_doc = " "*string(__module__)*"."*string(name)*"{T, U}" + name_doc *= "\n\nA supertype for quantities and levels of dimension `"*string(dims)*"` with a value of type `T` and units `U`." + name_doc *= "\n\nSee also: [`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)." + unit_doc = " "*string(__module__)*"."*string(uname)*"{U}" + unit_doc *= "\n\nA supertype for units of dimension `"*string(dims)*"`. " + unit_doc *= "Equivalent to `Unitful.Units{U, "*string(dims)*"}`." + unit_doc *= "\n\nSee also: [`Unitful.Units`](@ref)." + funit_doc = " "*string(__module__)*"."*string(funame)*"{U}" + funit_doc *= "\n\nA supertype for free units of dimension `"*string(dims)*"`. " + funit_doc *= "Equivalent to `Unitful.FreeUnits{U, "*string(dims)*"}`." + funit_doc *= "\n\nSee also: [`Unitful.FreeUnits`](@ref)." esc(quote - Base.@__doc__ const global ($name){T,U} = Union{ + const global ($name){T,U} = Union{ $Quantity{T,$dims,U}, $Level{L,S,$Quantity{T,$dims,U}} where {L,S}} const global ($uname){U} = $Units{U,$dims} const global ($funame){U} = $FreeUnits{U,$dims} + if ($autodocs) + @doc $name_doc ($name) + @doc $unit_doc ($uname) + @doc $funit_doc ($funame) + end nothing end) end +macro derived_dimension(name, dims) + esc(:(@derived_dimension($name,$dims,false))) +end """ @refunit(symb, name, abbr, dimension, tf) + @refunit(symb, name, abbr, dimension, tf, autodocs) Define a reference unit, typically SI. Rather than define conversion factors between each and every unit of a given dimension, conversion factors are given between each unit and a reference unit, defined by this macro. @@ -120,7 +152,8 @@ This macro extends [`Unitful.abbr`](@ref) so that the reference unit can be displayed in an abbreviated format. If `tf == true`, this macro generates symbols for every power of ten of the unit, using the standard SI prefixes. A `dimension` must be given ([`Unitful.Dimensions`](@ref) object) that specifies the dimension -of the reference unit. +of the reference unit. If `autodocs == true`, automatic documentation for +power-of-ten prefixes (if defined) will be added. In principle, users can use this macro, but it probably does not make much sense to do so. If you define a new (probably unphysical) dimension using @@ -139,7 +172,7 @@ Usage example: `@refunit m "m" Meter ๐‹ true` This example, found in `src/pkgdefaults.jl`, generates `km`, `m`, `cm`, ... """ -macro refunit(symb, abbr, name, dimension, tf) +macro refunit(symb, abbr, name, dimension, tf, autodocs) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -149,7 +182,7 @@ macro refunit(symb, abbr, name, dimension, tf) if tf push!(expr.args, quote - Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $dimension (1.0, 1) + Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $dimension (1.0, 1) $autodocs end) else push!(expr.args, quote @@ -164,12 +197,18 @@ macro refunit(symb, abbr, name, dimension, tf) esc(expr) end +macro refunit(symb,abbr,name,dimension,tf) + esc(:(@refunit($symb,$abbr,$name,$dimension,$tf,false))) +end """ @unit(symb,abbr,name,equals,tf) + @unit(symb,abbr,name,equals,tf,autodocs) Define a unit. Rather than specifying a dimension like in [`@refunit`](@ref), `equals` should be a [`Unitful.Quantity`](@ref) equal to one of the unit being defined. If `tf == true`, symbols will be made for each power-of-ten prefix. +If `autodocs == true`, automatic documentation for power-of-ten prefixes (if +defined) will be added. Returns the [`Unitful.FreeUnits`](@ref) object to which `symb` is bound. @@ -177,7 +216,7 @@ Usage example: `@unit mi "mi" Mile (201168//125)*m false` This example will *not* generate `kmi` (kilomiles). """ -macro unit(symb,abbr,name,equals,tf) +macro unit(symb,abbr,name,equals,tf,autodocs) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -191,7 +230,7 @@ macro unit(symb,abbr,name,equals,tf) if tf push!(expr.args, quote - Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $d $basef + Base.@__doc__ $Unitful.@prefixed_unit_symbols $symb $name $d $basef $autodocs end) else push!(expr.args, quote @@ -205,6 +244,9 @@ macro unit(symb,abbr,name,equals,tf) esc(expr) end +macro unit(symb,abbr,name,equals,tf) + esc(:(@unit($symb,$abbr,$name,$equals,$tf,false))) +end """ @affineunit(symb, abbr, offset) @@ -235,14 +277,15 @@ function basefactors_expr(m::Module, n, basefactor) end """ - @prefixed_unit_symbols(symb,name,dimension,basefactor) + @prefixed_unit_symbols(symb,name,dimension,basefactor,autodocs) Not called directly by the user. Given a unit symbol and a unit's name, -will define units for each possible SI power-of-ten prefix on that unit. +will define units for each possible SI power-of-ten prefix on that unit. If +`autodocs == true`, it will automatically generate documentation for these units. -Example: `@prefixed_unit_symbols m Meter ๐‹ (1.0,1)` results in `nm`, `cm`, `m`, `km`, ... -all getting defined in the calling namespace. +Example: `@prefixed_unit_symbols m Meter ๐‹ (1.0,1) true` results in `nm`, `cm`, `m`, `km`, ... +all getting defined in the calling namespace, with documentation automatically defined. """ -macro prefixed_unit_symbols(symb,name,user_dimension,basefactor) +macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -257,7 +300,7 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor) const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() if ($isbase) Base.@__doc__ $s - else + elseif ($autodocs) @doc $docstring1 $s end end From 18ed034fe4c10716d6c28351e6e92a7fde243a10 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Tue, 12 Oct 2021 13:56:37 -0500 Subject: [PATCH 25/43] Add dimension info in automatic prefixed unit docs. --- src/pkgdefaults.jl | 1 + src/user.jl | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 425e2eac..b65abb8d 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -725,6 +725,7 @@ Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do docstring = " Unitful."*string(sym)*"\n\n" docstring *= "A prefixed unit, equal to 10^"*string(k-3)*" kg." docstring *= " Note that `kg`, not `g`, is the base unit." + docstring *= "\n\nDimension: [`Unitful.๐Œ`](@ref)." docstring *= "\n\nSee also: [`Unitful.kg`](@ref)." run = quote @doc $docstring $sym end eval(run) diff --git a/src/user.jl b/src/user.jl index 39ac734f..574fb461 100644 --- a/src/user.jl +++ b/src/user.jl @@ -294,6 +294,7 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs) u = :($Unit{$n, $user_dimension}($k,1//1)) isbase = k==0 docstring1 = " "*string(__module__)*"."*string(s)*"\n\nA prefixed unit, equal to 10^"*string(k)*" "*string(symb)*"." + docstring1 *= "\n\nDimension: "*string(eval(user_dimension))*"." docstring1 *= "\n\nSee also: [`"*string(__module__)*"."*string(symb)*"`](@ref)." ea = quote $(basefactors_expr(__module__, n, basefactor)) From 91a16b843a3eccf250f59acf699df6be235b4d77 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Wed, 13 Oct 2021 12:26:22 -0500 Subject: [PATCH 26/43] Change method for adding dimensions to prefixed unit documentation Now no longer tries to `eval` stuff while running the macro. --- src/user.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/user.jl b/src/user.jl index 574fb461..fb4914e9 100644 --- a/src/user.jl +++ b/src/user.jl @@ -294,15 +294,16 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs) u = :($Unit{$n, $user_dimension}($k,1//1)) isbase = k==0 docstring1 = " "*string(__module__)*"."*string(s)*"\n\nA prefixed unit, equal to 10^"*string(k)*" "*string(symb)*"." - docstring1 *= "\n\nDimension: "*string(eval(user_dimension))*"." - docstring1 *= "\n\nSee also: [`"*string(__module__)*"."*string(symb)*"`](@ref)." + docstring1 *= "\n\nDimension: " + docstring2 = ".\n\nSee also: [`"*string(__module__)*"."*string(symb)*"`](@ref)." ea = quote $(basefactors_expr(__module__, n, basefactor)) const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() if ($isbase) Base.@__doc__ $s elseif ($autodocs) - @doc $docstring1 $s + adoc_str = $docstring1*string($user_dimension)*$docstring2 + @doc adoc_str $s end end push!(expr.args, ea) From 0ad0c016d8a4837a48b6a53c361a19f183b906fd Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Wed, 13 Oct 2021 12:33:42 -0500 Subject: [PATCH 27/43] Fixes to documentation and code structure for autodocs for various macros --- src/user.jl | 61 ++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/src/user.jl b/src/user.jl index fb4914e9..489ca74a 100644 --- a/src/user.jl +++ b/src/user.jl @@ -26,8 +26,7 @@ function register(unit_module::Module) end """ - @dimension(symb, abbr, name) - @dimension(symb, abbr, name, autodocs) + @dimension(symb, abbr, name, autodocs=false) Creates new dimensions. `name` will be used like an identifier in the type parameter for a [`Unitful.Dimension`](@ref) object. `symb` will be a symbol defined in the namespace from which this macro is called that is bound to a @@ -44,7 +43,10 @@ of the newly defined dimension. The type alias for quantities or levels is simpl `name`, and the type alias for units is given by `name*"Units"`, e.g. `LengthUnits`. Note that there is also `LengthFreeUnits`, for example, which is an alias for dispatching on `FreeUnits` with length dimensions. The aliases are not exported. -If `autodocs == true`, documentation will be automatically generated for these aliases. +If `autodocs == true`, docstrings will be automatically generated for these aliases. + +!!! compat "Unitful 1.10" + The `autodocs` argument requires Unitful 1.10 or later. Finally, if you define new dimensions with [`@dimension`](@ref) you will need to specify a preferred unit for that dimension with [`Unitful.preferunits`](@ref), @@ -55,7 +57,7 @@ Returns the `Dimensions` object to which `symb` is bound. Usage example from `src/pkgdefaults.jl`: `@dimension ๐‹ "๐‹" Length` """ -macro dimension(symb, abbr, name, autodocs) +macro dimension(symb, abbr, name, autodocs=false) s = Symbol(symb) x = Expr(:quote, name) uname = Symbol(name,"Units") @@ -87,17 +89,16 @@ macro dimension(symb, abbr, name, autodocs) $s end) end -macro dimension(symb, abbr, name) - esc(:(@dimension($symb,$abbr,$name,false))) -end """ - @derived_dimension(name, dims) - @derived_dimension(name, dims, autodocs) + @derived_dimension(name, dims, autodocs=false) Creates type aliases to allow dispatch on [`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref), and [`Unitful.Units`](@ref) objects of a derived dimension, like area, which is just length squared. The type aliases are not exported. -If `autodocs == true`, documentation will be automatically generated for these aliases. +If `autodocs == true`, docstrings will be automatically generated for these aliases. + +!!! compat "Unitful 1.10" + The `autodocs` argument requires Unitful 1.10 or later. `dims` is a [`Unitful.Dimensions`](@ref) object. @@ -136,14 +137,10 @@ macro derived_dimension(name, dims, autodocs) nothing end) end -macro derived_dimension(name, dims) - esc(:(@derived_dimension($name,$dims,false))) -end """ - @refunit(symb, name, abbr, dimension, tf) - @refunit(symb, name, abbr, dimension, tf, autodocs) + @refunit(symb, name, abbr, dimension, tf, autodocs=false) Define a reference unit, typically SI. Rather than define conversion factors between each and every unit of a given dimension, conversion factors are given between each unit and a reference unit, defined by this macro. @@ -152,8 +149,11 @@ This macro extends [`Unitful.abbr`](@ref) so that the reference unit can be displayed in an abbreviated format. If `tf == true`, this macro generates symbols for every power of ten of the unit, using the standard SI prefixes. A `dimension` must be given ([`Unitful.Dimensions`](@ref) object) that specifies the dimension -of the reference unit. If `autodocs == true`, automatic documentation for -power-of-ten prefixes (if defined) will be added. +of the reference unit. If `autodocs == true`, autogenerated docstrings for +SI-prefixed units will be added. This option has no effect when 'autodocs == false'. + +!!! compat "Unitful 1.10" + The `autodocs` argument requires Unitful 1.10 or later. In principle, users can use this macro, but it probably does not make much sense to do so. If you define a new (probably unphysical) dimension using @@ -172,7 +172,7 @@ Usage example: `@refunit m "m" Meter ๐‹ true` This example, found in `src/pkgdefaults.jl`, generates `km`, `m`, `cm`, ... """ -macro refunit(symb, abbr, name, dimension, tf, autodocs) +macro refunit(symb, abbr, name, dimension, tf, autodocs=false) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -197,18 +197,17 @@ macro refunit(symb, abbr, name, dimension, tf, autodocs) esc(expr) end -macro refunit(symb,abbr,name,dimension,tf) - esc(:(@refunit($symb,$abbr,$name,$dimension,$tf,false))) -end """ - @unit(symb,abbr,name,equals,tf) - @unit(symb,abbr,name,equals,tf,autodocs) + @unit(symb,abbr,name,equals,tf,autodocs=false) Define a unit. Rather than specifying a dimension like in [`@refunit`](@ref), `equals` should be a [`Unitful.Quantity`](@ref) equal to one of the unit being defined. If `tf == true`, symbols will be made for each power-of-ten prefix. -If `autodocs == true`, automatic documentation for power-of-ten prefixes (if -defined) will be added. +If `autodocs == true`, autogenerated docstrings for SI-prefixed units will be added. +This option has no effect when `autodocs == false`. + +!!! compat "Unitful 1.10" + The `autodocs` argument requires Unitful 1.10 or later. Returns the [`Unitful.FreeUnits`](@ref) object to which `symb` is bound. @@ -244,9 +243,6 @@ macro unit(symb,abbr,name,equals,tf,autodocs) esc(expr) end -macro unit(symb,abbr,name,equals,tf) - esc(:(@unit($symb,$abbr,$name,$equals,$tf,false))) -end """ @affineunit(symb, abbr, offset) @@ -277,15 +273,18 @@ function basefactors_expr(m::Module, n, basefactor) end """ - @prefixed_unit_symbols(symb,name,dimension,basefactor,autodocs) + @prefixed_unit_symbols(symb,name,dimension,basefactor,autodocs=false) Not called directly by the user. Given a unit symbol and a unit's name, will define units for each possible SI power-of-ten prefix on that unit. If -`autodocs == true`, it will automatically generate documentation for these units. +`autodocs == true`, it will automatically generate docstrings for these units. + +!!! compat "Unitful 1.10" + The `autodocs` argument requires Unitful 1.10 or later. Example: `@prefixed_unit_symbols m Meter ๐‹ (1.0,1) true` results in `nm`, `cm`, `m`, `km`, ... all getting defined in the calling namespace, with documentation automatically defined. """ -macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs) +macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) expr = Expr(:block) n = Meta.quot(Symbol(name)) From 41beaf88557dd4802e2784dbf94597a6bc3b88c9 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Thu, 14 Oct 2021 10:21:05 -0500 Subject: [PATCH 28/43] Apply suggestions from code review Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/pkgdefaults.jl | 16 +++++++++------- src/user.jl | 7 +++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index b65abb8d..ee20f7cf 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -219,15 +219,15 @@ substrate per s. \nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." @unit kat "kat" Katal 1mol/s true true " Unitful.percent -\nPercent, a unit meaning parts per hundred. +\nPercent, a unit meaning parts per hundred. Printed as "%". \nDimension: [`Unitful.NoDims`](@ref)." @unit percent "%" Percent 1//100 false true " Unitful.permille -\nPermille, a unit meaning parts per thousand. +\nPermille, a unit meaning parts per thousand. Printed as "โ€ฐ". \nDimension: [`Unitful.NoDims`](@ref)." @unit permille "โ€ฐ" Permille 1//1000 false true " Unitful.pertenthousand -\nPermyriad, a unit meaning parts per ten thousand. +\nPermyriad, a unit meaning parts per ten thousand. Printed as "โ€ฑ". \nDimension: [`Unitful.NoDims`](@ref)." @unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false true @@ -297,6 +297,7 @@ const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, ๐‹^2}(2, 1//1),), ๐‹^2}() # Volume # `l` is also an acceptable symbol for liters " Unitful.L + Unitful.l \nThe liter, a metric unit of volume, defined as 1000 cm^3. \nDimension: ๐‹^3. \nSee Also: [`Unitful.cm`](@ref)." @@ -312,8 +313,7 @@ end # Molarity " Unitful.M -\nA unit for measuring molar concentration; a 1 molar solution has 1 mol of -solute per L of solution. +\nA unit for measuring molar concentration, equal to 1 mol/L. \nDimension: ๐ ๐‹^-3. \nSee Also: [`Unitful.L`](@ref), [`Unitful.mol`](@ref)." @unit M "M" Molar 1mol/L true true @@ -374,6 +374,7 @@ const c0 = 299_792_458*m/s # exact const ฮผ0 = 4ฯ€*(1//10)^7*H/m # exact (but gets promoted to Float64...) const ยต0 = ฮผ0 # magnetic constant " Unitful.ฮต0 + Unitful.ฯต0 \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)." @@ -398,7 +399,7 @@ near the surface of the earth, defined by standard to be exactly 9.806,65 m / s^ const gn = 9.80665*m/s^2 # exact, standard acceleration of gravity " Unitful.h \nA quantity representing Planck's constant, defined as exactly -6.62607015 ร— 10^-34 J ร— s. +6.626,070,15 ร— 10^-34 J ร— s. \nDimension: ๐‹^2 ๐Œ ๐“^-1. \nSee also: [`Unitful.J`](@ref), [`Unitful.s`](@ref)." const h = 6.626_070_15e-34*J*s # exact, Planck constant @@ -521,7 +522,7 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nSee also: [`Unitful.cm`](@ref), [`Unitful.Mx`](@ref)" @unit Gauss "Gauss" Gauss (1//10_000)*T true true " Unitful.Oe -\nThe oersted, a CGS unit of magnetic H-field strength, defined as 1,000 ร— A / (4ฯ€ ร— m). +\nThe oersted, a CGS unit of magnetic H-field strength, defined as 1000 A / (4ฯ€ ร— m). \nDimension: ๐ˆ ๐‹^-1. \nSee also: [`Unitful.A`](@ref), [`Unitful.m`](@ref)" @unit Oe "Oe" Oersted (1_000/4ฯ€)*A/m true true @@ -563,6 +564,7 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nSee Also: [`Unitful.yd`](@ref)." @unit mi "mi" Mile 1760yd false true " Unitful.angstrom + Unitful.ร… \nThe angstrom, a metric unit of length defined as 1/10 nm. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.nm`](@ref)." diff --git a/src/user.jl b/src/user.jl index 489ca74a..01a2f772 100644 --- a/src/user.jl +++ b/src/user.jl @@ -215,7 +215,7 @@ Usage example: `@unit mi "mi" Mile (201168//125)*m false` This example will *not* generate `kmi` (kilomiles). """ -macro unit(symb,abbr,name,equals,tf,autodocs) +macro unit(symb,abbr,name,equals,tf,autodocs=false) expr = Expr(:block) n = Meta.quot(Symbol(name)) @@ -282,7 +282,7 @@ will define units for each possible SI power-of-ten prefix on that unit. If The `autodocs` argument requires Unitful 1.10 or later. Example: `@prefixed_unit_symbols m Meter ๐‹ (1.0,1) true` results in `nm`, `cm`, `m`, `km`, ... -all getting defined in the calling namespace, with documentation automatically defined. +all getting defined in the calling namespace, with docstrings automatically defined for SI-prefixed units. """ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) expr = Expr(:block) @@ -301,8 +301,7 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) if ($isbase) Base.@__doc__ $s elseif ($autodocs) - adoc_str = $docstring1*string($user_dimension)*$docstring2 - @doc adoc_str $s + @doc $docstring1*string($user_dimension)*$docstring2 $s end end push!(expr.args, ea) From ff2b5da3e5b00af4909db26ee1d92a4facf4be32 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Thu, 14 Oct 2021 10:38:15 -0500 Subject: [PATCH 29/43] Various format fixes and liters documentation changes. --- src/pkgdefaults.jl | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index ee20f7cf..11d21d23 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -219,15 +219,15 @@ substrate per s. \nSee also: [`Unitful.mol`](@ref), [`Unitful.s`](@ref)." @unit kat "kat" Katal 1mol/s true true " Unitful.percent -\nPercent, a unit meaning parts per hundred. Printed as "%". +\nPercent, a unit meaning parts per hundred. Printed as \"%\". \nDimension: [`Unitful.NoDims`](@ref)." @unit percent "%" Percent 1//100 false true " Unitful.permille -\nPermille, a unit meaning parts per thousand. Printed as "โ€ฐ". +\nPermille, a unit meaning parts per thousand. Printed as \"โ€ฐ\". \nDimension: [`Unitful.NoDims`](@ref)." @unit permille "โ€ฐ" Permille 1//1000 false true " Unitful.pertenthousand -\nPermyriad, a unit meaning parts per ten thousand. Printed as "โ€ฑ". +\nPermyriad, a unit meaning parts per ten thousand. Printed as \"โ€ฑ\". \nDimension: [`Unitful.NoDims`](@ref)." @unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false true @@ -305,9 +305,21 @@ const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, ๐‹^2}(2, 1//1),), ๐‹^2}() 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)))) - # NullLogger to ignore documentation overwrite errors - Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do - Core.eval(Unitful, :(@doc @doc($(Symbol(p,:L))) $(Symbol(p,:l)))) +end +@doc @doc(L) l +# NullLogger to ignore documentation overwrite errors +Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do + for (k,v) in prefixdict + if (k!=0) + sym_L = Symbol(v,:L) + sym_l = Symbol(v,:l) + docstring = " Unitful."*string(sym_L)*"\n Unitful."*string(sym_l)*"\n\n" + docstring *= "A prefixed unit, equal to 10^"*string(k-3)*" L." + docstring *= "\n\nDimension: ๐‹^3." + docstring *= "\n\nSee also: [`Unitful.L`](@ref)." + run = quote @doc $docstring $sym_l; @doc $docstring $sym_L end + eval(run) + end end end @@ -410,7 +422,7 @@ const h = 6.626_070_15e-34*J*s # exact, Planck constant const ฤง = h/2ฯ€ # hbar " Unitful.ฮฆ0 \nA quantity representing the superconducting magnetic flux quantum, defined as -h / (2 q). +h / (2 ร— q). \nDimension: ๐‹^2 ๐Œ ๐ˆ^-1 ๐“^-2. \nSee also: [`Unitful.h`](@ref), [`Unitful.q`](@ref)." const ฮฆ0 = h/(2q) # Superconducting magnetic flux quantum @@ -564,7 +576,7 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nSee Also: [`Unitful.yd`](@ref)." @unit mi "mi" Mile 1760yd false true " Unitful.angstrom - Unitful.ร… + Unitful.โ„ซ \nThe angstrom, a metric unit of length defined as 1/10 nm. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.nm`](@ref)." From ef09d565e7c0e6a7ee2eb94bb9352e878bdc7861 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Thu, 14 Oct 2021 10:43:12 -0500 Subject: [PATCH 30/43] Fix missing optional argument causing test failure --- src/user.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user.jl b/src/user.jl index 01a2f772..988fc45f 100644 --- a/src/user.jl +++ b/src/user.jl @@ -109,7 +109,7 @@ Usage examples: - `@derived_dimension Area ๐‹^2` gives `Area` and `AreaUnit` type aliases - `@derived_dimension Speed ๐‹/๐“` gives `Speed` and `SpeedUnit` type aliases """ -macro derived_dimension(name, dims, autodocs) +macro derived_dimension(name, dims, autodocs=false) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") name_doc = " "*string(__module__)*"."*string(name)*"{T, U}" From e3f10ff1781693f30f1ee8456b269a7a9554d5e9 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Thu, 14 Oct 2021 15:24:40 -0500 Subject: [PATCH 31/43] Remove no-longer-necessary NullLogger for liter and kilogram docs --- src/pkgdefaults.jl | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 11d21d23..2504f43d 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -301,25 +301,22 @@ 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 true +@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 -# NullLogger to ignore documentation overwrite errors -Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do - for (k,v) in prefixdict - if (k!=0) - sym_L = Symbol(v,:L) - sym_l = Symbol(v,:l) - docstring = " Unitful."*string(sym_L)*"\n Unitful."*string(sym_l)*"\n\n" - docstring *= "A prefixed unit, equal to 10^"*string(k-3)*" L." - docstring *= "\n\nDimension: ๐‹^3." - docstring *= "\n\nSee also: [`Unitful.L`](@ref)." - run = quote @doc $docstring $sym_l; @doc $docstring $sym_L end - eval(run) - end +for (k,v) in prefixdict + if (k!=0) + sym_L = Symbol(v,:L) + sym_l = Symbol(v,:l) + docstring = " Unitful."*string(sym_L)*"\n Unitful."*string(sym_l)*"\n\n" + docstring *= "A prefixed unit, equal to 10^"*string(k)*" L." + docstring *= "\n\nDimension: ๐‹^3." + docstring *= "\n\nSee also: [`Unitful.L`](@ref)." + run = quote @doc $docstring $sym_l; @doc $docstring $sym_L end + eval(run) end end @@ -732,9 +729,8 @@ end preferunits(kg) # others done in @refunit # Fix documentation for all kg based units -# Using a NullLogger is necessary to avoid documentation overwritten errors. -Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do - for (k,v) in prefixdict +for (k,v) in prefixdict + if (k!=3) sym = Symbol(v,:g) docstring = " Unitful."*string(sym)*"\n\n" docstring *= "A prefixed unit, equal to 10^"*string(k-3)*" kg." @@ -744,11 +740,11 @@ Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do run = quote @doc $docstring $sym end eval(run) end - @doc " Unitful.kg - \nThe kilogram, the SI base unit of mass. - Note that `kg`, not `g`, is the base unit. - \nDimension: [`Unitful.๐Œ`](@ref)." kg end +@doc " Unitful.kg +\nThe kilogram, the SI base unit of mass. +Note that `kg`, not `g`, is the base unit. +\nDimension: [`Unitful.๐Œ`](@ref)." kg """ Unitful.promote_to_derived() From ba0ed412395074a8f075363edb87fe547d9ead03 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Thu, 14 Oct 2021 15:26:28 -0500 Subject: [PATCH 32/43] Remove unnecessary autodocs arguments for non-SI-prefixed units --- src/pkgdefaults.jl | 62 +++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 2504f43d..a3eec5f1 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -106,7 +106,7 @@ const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T " Unitful.ยฐ \nThe degree, a unit of angle. There are 360ยฐ in a circle. \nDimension: [`Unitful.NoDims`](@ref)." -@unit ยฐ "ยฐ" Degree pi/180 false true +@unit ยฐ "ยฐ" Degree pi/180 false # For numerical accuracy, specific to the degree import Base: sind, cosd, tand, secd, cscd, cotd for (_x,_y) in ((:sin,:sind), (:cos,:cosd), (:tan,:tand), @@ -221,15 +221,15 @@ substrate per s. " Unitful.percent \nPercent, a unit meaning parts per hundred. Printed as \"%\". \nDimension: [`Unitful.NoDims`](@ref)." -@unit percent "%" Percent 1//100 false true +@unit percent "%" Percent 1//100 false " Unitful.permille \nPermille, a unit meaning parts per thousand. Printed as \"โ€ฐ\". \nDimension: [`Unitful.NoDims`](@ref)." -@unit permille "โ€ฐ" Permille 1//1000 false true +@unit permille "โ€ฐ" Permille 1//1000 false " Unitful.pertenthousand \nPermyriad, a unit meaning parts per ten thousand. Printed as \"โ€ฑ\". \nDimension: [`Unitful.NoDims`](@ref)." -@unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false true +@unit pertenthousand "โ€ฑ" Pertenthousand 1//10000 false # Temperature " Unitful.ยฐC @@ -244,22 +244,22 @@ substrate per s. to avoid confusion with the Julia function `min`. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.s`](@ref)." -@unit minute "minute" Minute 60s false true +@unit minute "minute" Minute 60s false " Unitful.hr \nThe hour, a unit of time defined as 60 minutes. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.minute`](@ref)." -@unit hr "hr" Hour 3600s false true +@unit hr "hr" Hour 3600s false " Unitful.d \nThe day, a unit of time defined as 24 hr. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.hr`](@ref)." -@unit d "d" Day 86400s false true +@unit d "d" Day 86400s false " Unitful.wk \nThe week, a unit of time, defined as 7 d. \nDimension: [`Unitful.๐“`](@ref). \nSee Also: [`Unitful.d`](@ref)." -@unit wk "wk" Week 604800s false true +@unit wk "wk" Week 604800s false " Unitful.yr \nThe year, a unit of time, defined as 365.25 d. \nDimension: [`Unitful.๐“`](@ref). @@ -269,12 +269,12 @@ to avoid confusion with the Julia function `min`. \nRevolutions per second, a unit of rotational speed, defined as 2ฯ€ rad / s. \nDimension: ๐“^-1. \nSee Also: [`Unitful.rad`](@ref), [`Unitful.s`](@ref)." -@unit rps "rps" RevolutionsPerSecond 2ฯ€*rad/s false true +@unit rps "rps" RevolutionsPerSecond 2ฯ€*rad/s false " Unitful.rpm \nRevolutions per minute, a unit of rotational speed, defined as 2ฯ€ rad / minute. \nDimension: ๐“^-1. \nSee Also: [`Unitful.minute`](@ref), [`Unitful.rad`](@ref)." -@unit rpm "rpm" RevolutionsPerMinute 2ฯ€*rad/minute false true +@unit rpm "rpm" RevolutionsPerMinute 2ฯ€*rad/minute false # Area # The hectare is used more frequently than any other power-of-ten of an are. @@ -282,7 +282,7 @@ to avoid confusion with the Julia function `min`. \nThe are, a metric unit of area, defined as 100 m^2. \nDimension: ๐‹^2. \nSee Also: [`Unitful.m`](@ref)." -@unit a "a" Are 100m^2 false true +@unit a "a" Are 100m^2 false " Unitful.ha \nThe hectare, a metric unit of area, defined as 100 a. \nDimension: ๐‹^2. @@ -356,7 +356,7 @@ const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... \nThe standard atmosphere, a unit of pressure, defined as 101,325 Pa. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee also: [`Unitful.Pa`](@ref)." -@unit atm "atm" Atmosphere 101325Pa false true +@unit atm "atm" Atmosphere 101325Pa false " Unitful.Torr \nThe torr, a unit of pressure, defined as 1/760 atm. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. @@ -375,7 +375,7 @@ const c0 = 299_792_458*m/s # exact 2.997,924,58 ร— 10^8 m/s. \nDimension: ๐‹ ๐“^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit c "c" SpeedOfLight 1c0 false true +@unit c "c" SpeedOfLight 1c0 false " Unitful.ฮผ0 \nA quantity representing the vacuum permeability constant, defined as 4ฯ€ ร— 10^-7 H / m. \nDimension: ๐‹ ๐Œ ๐ˆ^-2 ๐“^-2. @@ -483,7 +483,7 @@ mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 ร— 10^-2 (the CODATA 2018 recommended value). \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.kg`](@ref)." -@unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false true # (50) +@unit u "u" UnifiedAtomicMassUnit 1.660_539_066_60e-27*kg false # (50) # Acceleration " Unitful.ge @@ -491,7 +491,7 @@ mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 ร— 10^-2 earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^2. \nDimension: ๐‹ ๐“^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." -@unit ge "ge" EarthGravity gn false true +@unit ge "ge" EarthGravity gn false # CGS units @@ -551,33 +551,33 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe inch, a US customary unit of length defined as 2.54 cm. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.cm`](@ref)." -@unit inch "inch" Inch (254//10000)*m false true +@unit inch "inch" Inch (254//10000)*m false " Unitful.mil \nThe mil, a US customary unit of length defined as 1/1000 inch. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.inch`](@ref)." -@unit mil "mil" Mil (1//1000)*inch false true +@unit mil "mil" Mil (1//1000)*inch false " Unitful.ft \nThe foot, a US customary unit of length defined as 12 inch. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.inch`](@ref)." -@unit ft "ft" Foot 12inch false true +@unit ft "ft" Foot 12inch false " Unitful.yd \nThe yard, a US customary unit of length defined as 3 ft. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.ft`](@ref)." -@unit yd "yd" Yard 3ft false true +@unit yd "yd" Yard 3ft false " Unitful.mi \nThe mile, a US customary unit of length defined as 1760 yd. \nDimension: [`Unitful.๐‹`](@ref). \nSee Also: [`Unitful.yd`](@ref)." -@unit mi "mi" Mile 1760yd false true +@unit mi "mi" Mile 1760yd false " Unitful.angstrom Unitful.โ„ซ \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 true +@unit angstrom "โ„ซ" Angstrom (1//10)*nm false # U+00c5 (opt-shift-A on macOS) and U+212b ('\Angstrom' in REPL) look identical: @doc @doc(angstrom) const ร… = โ„ซ = angstrom @@ -586,14 +586,14 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe acre, a US customary unit of area defined as 4840 yd^2. \nDimension: ๐‹^2. \nSee Also: [`Unitful.yd`](@ref)." -@unit ac "ac" Acre (316160658//78125)*m^2 false true +@unit ac "ac" Acre (316160658//78125)*m^2 false # Temperatures " Unitful.Ra \nThe rankine, a US customary unit of temperature defined as 5/9 K. \nDimension: [`Unitful.๐šฏ`](@ref). \nSee Also: [`Unitful.K`](@ref)." -@unit Ra "Ra" Rankine (5//9)*K false true +@unit Ra "Ra" Rankine (5//9)*K false " Unitful.ยฐF \nThe degree Fahrenheit, a US customary unit of temperature, defined such that 0 ยฐF = 459.67 Ra. \nDimension: [`Unitful.๐šฏ`](@ref). @@ -605,34 +605,34 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe pound-mass, a US customary unit of mass defined as exactly 0.453,592,37 kg. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.kg`](@ref)." -@unit lb "lb" Pound 0.45359237kg false true # is exact +@unit lb "lb" Pound 0.45359237kg false # is exact " Unitful.oz \nThe ounce, a US customary unit of mass defined as 1/16 lb. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lb`](@ref)." -@unit oz "oz" Ounce lb//16 false true +@unit oz "oz" Ounce lb//16 false " Unitful.slug \nThe slug, a US customary unit of mass defined as 1 lbf ร— s^2 / ft. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.s`](@ref), [`Unitful.ft`](@ref)." -@unit slug "slug" Slug 1lb*ge*s^2/ft false true +@unit slug "slug" Slug 1lb*ge*s^2/ft false " Unitful.dr \nThe dram, a US customary unit of mass defined as 1/16 oz. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.oz`](@ref)." -@unit dr "dr" Dram oz//16 false true +@unit dr "dr" Dram oz//16 false " Unitful.gr \nThe grain, a US customary unit of mass defined as 1/7000 lb. \nDimension: [`Unitful.๐Œ`](@ref). \nSee Also: [`Unitful.lb`](@ref)." -@unit gr "gr" Grain (32//875)*dr false true +@unit gr "gr" Grain (32//875)*dr false # Force " Unitful.lbf \nThe pound-force, a US customary unit of force defined as 1 lb ร— ge. \nDimension: ๐‹ ๐Œ ๐“^-2. \nSee Also: [`Unitful.lb`](@ref), [`Unitful.ge`](@ref)." -@unit lbf "lbf" PoundsForce 1lb*ge false true +@unit lbf "lbf" PoundsForce 1lb*ge false # Energy # Use ISO 31-4 for BTU definition @@ -645,14 +645,14 @@ earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^ \nThe British thermal unit, a US customary unit of heat defined by ISO 31-4 as exactly 1055.06 J. \nDimension: ๐‹^2 ๐Œ ๐“^-2. \nSee Also: [`Unitful.J`](@ref)." -@unit btu "btu" BritishThermalUnit 1055.06J false true +@unit btu "btu" BritishThermalUnit 1055.06J false # Pressure " Unitful.psi \nPounds per square inch, a US customary unit of pressure defined as 1 lbf / inch^2. \nDimension: ๐Œ ๐‹^-1 ๐“^-2. \nSee Also: [`Unitful.lbf`](@ref), [`Unitful.inch`](@ref)." -@unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false true +@unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false ######### # Logarithmic scales and units From 34ed5335c206e36ad89a7959ff6aa6aba6b3f3ad Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Fri, 15 Oct 2021 09:25:10 -0500 Subject: [PATCH 33/43] Apply suggestions from code review Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/user.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/user.jl b/src/user.jl index 988fc45f..e37c893a 100644 --- a/src/user.jl +++ b/src/user.jl @@ -62,17 +62,18 @@ macro dimension(symb, abbr, name, autodocs=false) x = Expr(:quote, name) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") + name_links = __module__ == Unitful ? "[`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)" : "`Unitful.Quantity`, `Unitful.Level`" name_doc = " "*string(__module__)*"."*string(name)*"{T, U}" name_doc *= "\n\nA supertype for quantities and levels of dimension [`"*string(__module__)*"."*string(s)*"`](@ref) with a value of type `T` and units `U`." - name_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), [`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)." + name_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), "*name_links*"." unit_doc = " "*string(__module__)*"."*string(uname)*"{U}" unit_doc *= "\n\nA supertype for units of dimension [`"*string(__module__)*"."*string(s)*"`](@ref). " unit_doc *= "Equivalent to `Unitful.Units{U, "*string(__module__)*"."*string(s)*"}`." unit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), [`Unitful.Units`](@ref)." funit_doc = " "*string(__module__)*"."*string(funame)*"{U}" - funit_doc *= "\n\nA supertype for free units of dimension [`"*string(__module__)*"."*string(s)*"`](@ref). " + funit_doc *= "\n\nA supertype for [`Unitful.FreeUnits`](@ref) of dimension [`"*string(__module__)*"."*string(s)*"`](@ref). " funit_doc *= "Equivalent to `Unitful.FreeUnits{U, "*string(__module__)*"."*string(s)*"}`." - funit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), [`Unitful.FreeUnits`](@ref)." + funit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref)." esc(quote $Unitful.abbr(::$Dimension{$x}) = $abbr Base.@__doc__ const global $s = $Dimensions{($Dimension{$x}(1),)}() From 628215d9103255bab0e2ddc7a44649cd23428035 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Fri, 15 Oct 2021 09:44:22 -0500 Subject: [PATCH 34/43] Fix invalid links being created in non-Unitful documentation --- src/user.jl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/user.jl b/src/user.jl index e37c893a..5f664c9a 100644 --- a/src/user.jl +++ b/src/user.jl @@ -63,17 +63,19 @@ macro dimension(symb, abbr, name, autodocs=false) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") name_links = __module__ == Unitful ? "[`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)" : "`Unitful.Quantity`, `Unitful.Level`" + unit_links = __module__ == Unitful ? "[`Unitful.Units`](@ref)" : "Unitful.Units" + funit_links = __module__ == Unitful ? "[`Unitful.FreeUnits`](@ref)" : "Unitful.FreeUnits" name_doc = " "*string(__module__)*"."*string(name)*"{T, U}" name_doc *= "\n\nA supertype for quantities and levels of dimension [`"*string(__module__)*"."*string(s)*"`](@ref) with a value of type `T` and units `U`." name_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), "*name_links*"." unit_doc = " "*string(__module__)*"."*string(uname)*"{U}" unit_doc *= "\n\nA supertype for units of dimension [`"*string(__module__)*"."*string(s)*"`](@ref). " unit_doc *= "Equivalent to `Unitful.Units{U, "*string(__module__)*"."*string(s)*"}`." - unit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), [`Unitful.Units`](@ref)." + unit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), "*unit_links*"." funit_doc = " "*string(__module__)*"."*string(funame)*"{U}" funit_doc *= "\n\nA supertype for [`Unitful.FreeUnits`](@ref) of dimension [`"*string(__module__)*"."*string(s)*"`](@ref). " funit_doc *= "Equivalent to `Unitful.FreeUnits{U, "*string(__module__)*"."*string(s)*"}`." - funit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref)." + funit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), "*funit_links*"." esc(quote $Unitful.abbr(::$Dimension{$x}) = $abbr Base.@__doc__ const global $s = $Dimensions{($Dimension{$x}(1),)}() @@ -113,17 +115,20 @@ Usage examples: macro derived_dimension(name, dims, autodocs=false) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") + name_links = __module__ == Unitful ? "[`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)" : "`Unitful.Quantity`, `Unitful.Level`" + unit_links = __module__ == Unitful ? "[`Unitful.Units`](@ref)" : "Unitful.Units" + funit_links = __module__ == Unitful ? "[`Unitful.FreeUnits`](@ref)" : "Unitful.FreeUnits" name_doc = " "*string(__module__)*"."*string(name)*"{T, U}" name_doc *= "\n\nA supertype for quantities and levels of dimension `"*string(dims)*"` with a value of type `T` and units `U`." - name_doc *= "\n\nSee also: [`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)." + name_doc *= "\n\nSee also: "*name_links*"." unit_doc = " "*string(__module__)*"."*string(uname)*"{U}" unit_doc *= "\n\nA supertype for units of dimension `"*string(dims)*"`. " unit_doc *= "Equivalent to `Unitful.Units{U, "*string(dims)*"}`." - unit_doc *= "\n\nSee also: [`Unitful.Units`](@ref)." + unit_doc *= "\n\nSee also: "*unit_links*"." funit_doc = " "*string(__module__)*"."*string(funame)*"{U}" funit_doc *= "\n\nA supertype for free units of dimension `"*string(dims)*"`. " funit_doc *= "Equivalent to `Unitful.FreeUnits{U, "*string(dims)*"}`." - funit_doc *= "\n\nSee also: [`Unitful.FreeUnits`](@ref)." + funit_doc *= "\n\nSee also: "*funit_links*"." esc(quote const global ($name){T,U} = Union{ $Quantity{T,$dims,U}, From 661110366fd8ec5c23afcc20def53b475d259be0 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Fri, 15 Oct 2021 09:59:50 -0500 Subject: [PATCH 35/43] Add spaced out column for autogen parameter where possible --- src/pkgdefaults.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index a3eec5f1..238dc181 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -4,25 +4,25 @@ # dimensions from units, and also helps prevent common namespace collisions. " Unitful.๐‹ \nA dimension representing length." -@dimension ๐‹ "๐‹" Length true +@dimension ๐‹ "๐‹" Length true " Unitful.๐Œ \nA dimension representing mass." -@dimension ๐Œ "๐Œ" Mass true +@dimension ๐Œ "๐Œ" Mass true " Unitful.๐“ \nA dimension representing time." -@dimension ๐“ "๐“" Time true +@dimension ๐“ "๐“" Time true " Unitful.๐ˆ \nA dimension representing electric current." -@dimension ๐ˆ "๐ˆ" Current true +@dimension ๐ˆ "๐ˆ" Current true " Unitful.๐šฏ \nA dimension representing thermodynamic temperature." @dimension ๐šฏ "๐šฏ" Temperature true # This one is \bfTheta " Unitful.๐‰ \nA dimension representing luminous intensity." -@dimension ๐‰ "๐‰" Luminosity true +@dimension ๐‰ "๐‰" Luminosity true " Unitful.๐ \nA dimension representing amount of substance." -@dimension ๐ "๐" Amount true +@dimension ๐ "๐" Amount true const RelativeScaleTemperature = Quantity{T, ๐šฏ, <:AffineUnits} where T const AbsoluteScaleTemperature = Quantity{T, ๐šฏ, <:ScalarUnits} where T From 22e59bc8800aeb919416b9429e545b6a18a49a24 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 16 Oct 2021 13:56:48 -0500 Subject: [PATCH 36/43] Apply suggestions from code review Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/pkgdefaults.jl | 24 +++++++----- src/user.jl | 92 ++++++++++++++++++++++++++-------------------- 2 files changed, 67 insertions(+), 49 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 238dc181..9d8b6c8d 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -311,10 +311,13 @@ for (k,v) in prefixdict if (k!=0) sym_L = Symbol(v,:L) sym_l = Symbol(v,:l) - docstring = " Unitful."*string(sym_L)*"\n Unitful."*string(sym_l)*"\n\n" - docstring *= "A prefixed unit, equal to 10^"*string(k)*" L." - docstring *= "\n\nDimension: ๐‹^3." - docstring *= "\n\nSee also: [`Unitful.L`](@ref)." + docstring = """ + Unitful.$sym_L + Unitful.$sym_l + \nA prefixed unit, equal to 10^$k L. + \nDimension: ๐‹^3. + \nSee also: [`Unitful.L`](@ref). + """ run = quote @doc $docstring $sym_l; @doc $docstring $sym_L end eval(run) end @@ -730,13 +733,14 @@ end preferunits(kg) # others done in @refunit # Fix documentation for all kg based units for (k,v) in prefixdict - if (k!=3) + if k != 3 sym = Symbol(v,:g) - docstring = " Unitful."*string(sym)*"\n\n" - docstring *= "A prefixed unit, equal to 10^"*string(k-3)*" kg." - docstring *= " Note that `kg`, not `g`, is the base unit." - docstring *= "\n\nDimension: [`Unitful.๐Œ`](@ref)." - docstring *= "\n\nSee also: [`Unitful.kg`](@ref)." + docstring = """ + Unitful.$sym + \nA prefixed unit, equal to 10^$(k-3) kg. Note that `kg`, not `g`, is the base unit. + \nDimension: [`Unitful.๐Œ`](@ref). + \nSee also: [`Unitful.kg`](@ref). + """ run = quote @doc $docstring $sym end eval(run) end diff --git a/src/user.jl b/src/user.jl index 5f664c9a..fef35ad4 100644 --- a/src/user.jl +++ b/src/user.jl @@ -63,19 +63,26 @@ macro dimension(symb, abbr, name, autodocs=false) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") name_links = __module__ == Unitful ? "[`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)" : "`Unitful.Quantity`, `Unitful.Level`" - unit_links = __module__ == Unitful ? "[`Unitful.Units`](@ref)" : "Unitful.Units" - funit_links = __module__ == Unitful ? "[`Unitful.FreeUnits`](@ref)" : "Unitful.FreeUnits" - name_doc = " "*string(__module__)*"."*string(name)*"{T, U}" - name_doc *= "\n\nA supertype for quantities and levels of dimension [`"*string(__module__)*"."*string(s)*"`](@ref) with a value of type `T` and units `U`." - name_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), "*name_links*"." - unit_doc = " "*string(__module__)*"."*string(uname)*"{U}" - unit_doc *= "\n\nA supertype for units of dimension [`"*string(__module__)*"."*string(s)*"`](@ref). " - unit_doc *= "Equivalent to `Unitful.Units{U, "*string(__module__)*"."*string(s)*"}`." - unit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), "*unit_links*"." - funit_doc = " "*string(__module__)*"."*string(funame)*"{U}" - funit_doc *= "\n\nA supertype for [`Unitful.FreeUnits`](@ref) of dimension [`"*string(__module__)*"."*string(s)*"`](@ref). " - funit_doc *= "Equivalent to `Unitful.FreeUnits{U, "*string(__module__)*"."*string(s)*"}`." - funit_doc *= "\n\nSee also: [`"*string(__module__)*"."*string(s)*"`](@ref), "*funit_links*"." + unit_links = __module__ == Unitful ? "[`Unitful.Units`](@ref)" : "`Unitful.Units`" + funit_links = __module__ == Unitful ? "[`Unitful.FreeUnits`](@ref)" : "`Unitful.FreeUnits`" + name_doc = """ + $__module__.$name{T, U} + \nA supertype for quantities and levels of dimension [`$__module__.$s`](@ref) with a value + of type `T` and units `U`. + \nSee also: [`$__module__.$s`](@ref), $name_links. + """ + unit_doc = """ + $__module__.$uname{U} + \nA supertype for units of dimension [`$__module__.$s`](@ref). Equivalent to + `Unitful.Units{U, $__module__.$s}`. + \nSee also: [`$__module__.$s`](@ref), $unit_links. + """ + funit_doc = """ + $__module__.$funame{U} + \nA supertype for $funit_links of dimension [`$__module__.$s`](@ref). Equivalent to + `Unitful.FreeUnits{U, $__module__.$s}`. + \nSee also: [`$__module__.$s`](@ref). + """ esc(quote $Unitful.abbr(::$Dimension{$x}) = $abbr Base.@__doc__ const global $s = $Dimensions{($Dimension{$x}(1),)}() @@ -84,10 +91,10 @@ macro dimension(symb, abbr, name, autodocs=false) $Level{L,S,$Quantity{T,$s,U}} where {L,S}} const global ($uname){U} = $Units{U,$s} const global ($funame){U} = $FreeUnits{U,$s} - if ($autodocs) - @doc $name_doc ($name) - @doc $unit_doc ($uname) - @doc $funit_doc ($funame) + if $autodocs + @doc $name_doc $name + @doc $unit_doc $uname + @doc $funit_doc $funame end $s end) @@ -116,29 +123,34 @@ macro derived_dimension(name, dims, autodocs=false) uname = Symbol(name,"Units") funame = Symbol(name,"FreeUnits") name_links = __module__ == Unitful ? "[`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)" : "`Unitful.Quantity`, `Unitful.Level`" - unit_links = __module__ == Unitful ? "[`Unitful.Units`](@ref)" : "Unitful.Units" - funit_links = __module__ == Unitful ? "[`Unitful.FreeUnits`](@ref)" : "Unitful.FreeUnits" - name_doc = " "*string(__module__)*"."*string(name)*"{T, U}" - name_doc *= "\n\nA supertype for quantities and levels of dimension `"*string(dims)*"` with a value of type `T` and units `U`." - name_doc *= "\n\nSee also: "*name_links*"." - unit_doc = " "*string(__module__)*"."*string(uname)*"{U}" - unit_doc *= "\n\nA supertype for units of dimension `"*string(dims)*"`. " - unit_doc *= "Equivalent to `Unitful.Units{U, "*string(dims)*"}`." - unit_doc *= "\n\nSee also: "*unit_links*"." - funit_doc = " "*string(__module__)*"."*string(funame)*"{U}" - funit_doc *= "\n\nA supertype for free units of dimension `"*string(dims)*"`. " - funit_doc *= "Equivalent to `Unitful.FreeUnits{U, "*string(dims)*"}`." - funit_doc *= "\n\nSee also: "*funit_links*"." + unit_links = __module__ == Unitful ? "[`Unitful.Units`](@ref)" : "`Unitful.Units`" + funit_links = __module__ == Unitful ? "[`Unitful.FreeUnits`](@ref)" : "`Unitful.FreeUnits`" + name_doc = """ + $__module__.$name{T, U} + \nA supertype for quantities and levels of dimension `$dims` with a value of type `T` and + units `U`. + \nSee also: $name_links. + """ + unit_doc = """ + $__module__.$uname{U} + \nA supertype for units of dimension `$dims`. Equivalent to `Unitful.Units{U, $dims}`. + \nSee also: $unit_links. + """ + funit_doc = """ + $__module__.$funame{U} + \nA supertype for $funit_links of dimension `$dims`. Equivalent to + `Unitful.FreeUnits{U, $dims}`. + """ esc(quote const global ($name){T,U} = Union{ $Quantity{T,$dims,U}, $Level{L,S,$Quantity{T,$dims,U}} where {L,S}} const global ($uname){U} = $Units{U,$dims} const global ($funame){U} = $FreeUnits{U,$dims} - if ($autodocs) - @doc $name_doc ($name) - @doc $unit_doc ($uname) - @doc $funit_doc ($funame) + if $autodocs + @doc $name_doc $name + @doc $unit_doc $uname + @doc $funit_doc $funame end nothing end) @@ -298,15 +310,17 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) s = Symbol(v,symb) u = :($Unit{$n, $user_dimension}($k,1//1)) isbase = k==0 - docstring1 = " "*string(__module__)*"."*string(s)*"\n\nA prefixed unit, equal to 10^"*string(k)*" "*string(symb)*"." - docstring1 *= "\n\nDimension: " - docstring2 = ".\n\nSee also: [`"*string(__module__)*"."*string(symb)*"`](@ref)." + docstring1 = """ + $__module__.$s + \nA prefixed unit, equal to 10^$k $symb. + \nDimension: """ + docstring2 = """\n\nSee also: [`$__module__.$symb`](@ref)." ea = quote $(basefactors_expr(__module__, n, basefactor)) const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() - if ($isbase) + if $isbase Base.@__doc__ $s - elseif ($autodocs) + elseif $autodocs @doc $docstring1*string($user_dimension)*$docstring2 $s end end From 9de5ba47f29655d96c9e2520aae3894760419e17 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 16 Oct 2021 14:28:05 -0500 Subject: [PATCH 37/43] Update src/user.jl Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/user.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user.jl b/src/user.jl index fef35ad4..24471ed1 100644 --- a/src/user.jl +++ b/src/user.jl @@ -314,7 +314,7 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) $__module__.$s \nA prefixed unit, equal to 10^$k $symb. \nDimension: """ - docstring2 = """\n\nSee also: [`$__module__.$symb`](@ref)." + docstring2 = "\n\nSee also: [`$__module__.$symb`](@ref)." ea = quote $(basefactors_expr(__module__, n, basefactor)) const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() From 4c4f39566337f189d26968819627ba71efffc32b Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 16 Oct 2021 15:15:17 -0500 Subject: [PATCH 38/43] Add tests for autodocs --- test/runtests.jl | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 3e96550c..009525c4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1797,6 +1797,51 @@ end end end +module DocUnits + using Unitful + using Unitful: ๐‹ + "dimension docs" + @dimension ๐ƒ "๐ƒ" DocDimension true + @derived_dimension DerivedDocDimension ๐ƒ*๐‹ true + "refunit docs" + @refunit dRefFoo "dRefFoo" DRefFoo ๐ƒ true true + "unit docs" + @unit dFoo "dFoo" DFoo 1*dRefFoo*u"m" true true +end + +@testset "Docs" begin + @test string(@doc DocUnits.๐ƒ) == "dimension docs\n" + @test string(@doc DocUnits.dRefFoo) == "refunit docs\n" + @test string(@doc DocUnits.dFoo) == "unit docs\n" + @test string(@doc DocUnits.DocDimension) == """ + ```\n$(@__MODULE__).DocUnits.DocDimension{T, U}\n```\n + A supertype for quantities and levels of dimension [`$(@__MODULE__).DocUnits.๐ƒ`](@ref) with a value of type `T` and units `U`.\n + See also: [`$(@__MODULE__).DocUnits.๐ƒ`](@ref), `Unitful.Quantity`, `Unitful.Level`.\n""" + @test string(@doc DocUnits.DocDimensionUnits) == """ + ```\n$(@__MODULE__).DocUnits.DocDimensionUnits{U}\n```\n + A supertype for units of dimension [`$(@__MODULE__).DocUnits.๐ƒ`](@ref). Equivalent to `Unitful.Units{U, $(@__MODULE__).DocUnits.๐ƒ}`.\n + See also: [`$(@__MODULE__).DocUnits.๐ƒ`](@ref), `Unitful.Units`.\n""" + @test string(@doc DocUnits.DocDimensionFreeUnits) == """ + ```\n$(@__MODULE__).DocUnits.DocDimensionFreeUnits{U}\n```\n + A supertype for `Unitful.FreeUnits` of dimension [`$(@__MODULE__).DocUnits.๐ƒ`](@ref). Equivalent to `Unitful.FreeUnits{U, $(@__MODULE__).DocUnits.๐ƒ}`.\n + See also: [`$(@__MODULE__).DocUnits.๐ƒ`](@ref).\n""" + @test string(@doc DocUnits.DerivedDocDimension) == """ + ```\n$(@__MODULE__).DocUnits.DerivedDocDimension{T, U}\n```\n + A supertype for quantities and levels of dimension `๐ƒ * ๐‹` with a value of type `T` and units `U`.\n + See also: `Unitful.Quantity`, `Unitful.Level`.\n""" + @test string(@doc DocUnits.DerivedDocDimensionUnits) == """ + ```\n$(@__MODULE__).DocUnits.DerivedDocDimensionUnits{U}\n```\n + A supertype for units of dimension `๐ƒ * ๐‹`. Equivalent to `Unitful.Units{U, ๐ƒ * ๐‹}`.\n + See also: `Unitful.Units`.\n""" + @test string(@doc DocUnits.DerivedDocDimensionFreeUnits) == """ + ```\n$(@__MODULE__).DocUnits.DerivedDocDimensionFreeUnits{U}\n```\n + A supertype for `Unitful.FreeUnits` of dimension `๐ƒ * ๐‹`. Equivalent to `Unitful.FreeUnits{U, ๐ƒ * ๐‹}`.\n""" + @test string(@doc DocUnits.kdFoo) == """ + ```\n$(@__MODULE__).DocUnits.kdFoo\n```\n + A prefixed unit, equal to 10^3 dFoo.\n\nDimension: ๐ƒ ๐‹\n + See also: [`$(@__MODULE__).DocUnits.dFoo`](@ref).\n""" +end + # Test precompiled Unitful extension modules load_path = mktempdir() load_cache_path = mktempdir() From e48b49d31bc82925532e5cc0838f2c7c73e8402c Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 16 Oct 2021 15:18:09 -0500 Subject: [PATCH 39/43] Add test for prefixed reference units --- test/runtests.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 009525c4..df09fe0f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1840,6 +1840,10 @@ end ```\n$(@__MODULE__).DocUnits.kdFoo\n```\n A prefixed unit, equal to 10^3 dFoo.\n\nDimension: ๐ƒ ๐‹\n See also: [`$(@__MODULE__).DocUnits.dFoo`](@ref).\n""" + @test string(@doc DocUnits.kdRefFoo) == """ + ```\n$(@__MODULE__).DocUnits.kdRefFoo\n```\n + A prefixed unit, equal to 10^3 dRefFoo.\n\nDimension: ๐ƒ\n + See also: [`$(@__MODULE__).DocUnits.dRefFoo`](@ref).\n""" end # Test precompiled Unitful extension modules From 1569d249e33886e4397252202f3b05dc39535fc0 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Sat, 16 Oct 2021 17:31:28 -0500 Subject: [PATCH 40/43] Hopefully fix docstrings and docstring tests on Julia-1.0 --- src/pkgdefaults.jl | 18 ++++++---- src/user.jl | 69 ++++++++++++++++++++--------------- test/runtests.jl | 89 ++++++++++++++++++++++++++++++++++------------ 3 files changed, 119 insertions(+), 57 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 9d8b6c8d..73e93f6b 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -314,9 +314,12 @@ for (k,v) in prefixdict docstring = """ Unitful.$sym_L Unitful.$sym_l - \nA prefixed unit, equal to 10^$k L. - \nDimension: ๐‹^3. - \nSee also: [`Unitful.L`](@ref). + + A prefixed unit, equal to 10^$k L. + + Dimension: ๐‹^3. + + See also: [`Unitful.L`](@ref). """ run = quote @doc $docstring $sym_l; @doc $docstring $sym_L end eval(run) @@ -737,9 +740,12 @@ for (k,v) in prefixdict sym = Symbol(v,:g) docstring = """ Unitful.$sym - \nA prefixed unit, equal to 10^$(k-3) kg. Note that `kg`, not `g`, is the base unit. - \nDimension: [`Unitful.๐Œ`](@ref). - \nSee also: [`Unitful.kg`](@ref). + + A prefixed unit, equal to 10^$(k-3) kg. Note that `kg`, not `g`, is the base unit. + + Dimension: [`Unitful.๐Œ`](@ref). + + See also: [`Unitful.kg`](@ref). """ run = quote @doc $docstring $sym end eval(run) diff --git a/src/user.jl b/src/user.jl index 24471ed1..b77c28b3 100644 --- a/src/user.jl +++ b/src/user.jl @@ -65,23 +65,29 @@ macro dimension(symb, abbr, name, autodocs=false) name_links = __module__ == Unitful ? "[`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)" : "`Unitful.Quantity`, `Unitful.Level`" unit_links = __module__ == Unitful ? "[`Unitful.Units`](@ref)" : "`Unitful.Units`" funit_links = __module__ == Unitful ? "[`Unitful.FreeUnits`](@ref)" : "`Unitful.FreeUnits`" - name_doc = """ - $__module__.$name{T, U} - \nA supertype for quantities and levels of dimension [`$__module__.$s`](@ref) with a value - of type `T` and units `U`. - \nSee also: [`$__module__.$s`](@ref), $name_links. - """ - unit_doc = """ - $__module__.$uname{U} - \nA supertype for units of dimension [`$__module__.$s`](@ref). Equivalent to - `Unitful.Units{U, $__module__.$s}`. - \nSee also: [`$__module__.$s`](@ref), $unit_links. - """ + name_doc = """ + $__module__.$name{T, U} + + A supertype for quantities and levels of dimension [`$__module__.$s`](@ref) with a value + of type `T` and units `U`. + + See also: [`$__module__.$s`](@ref), $name_links. + """ + unit_doc = """ + $__module__.$uname{U} + + A supertype for units of dimension [`$__module__.$s`](@ref). Equivalent to + `Unitful.Units{U, $__module__.$s}`. + + See also: [`$__module__.$s`](@ref), $unit_links. + """ funit_doc = """ $__module__.$funame{U} - \nA supertype for $funit_links of dimension [`$__module__.$s`](@ref). Equivalent to + + A supertype for $funit_links of dimension [`$__module__.$s`](@ref). Equivalent to `Unitful.FreeUnits{U, $__module__.$s}`. - \nSee also: [`$__module__.$s`](@ref). + + See also: [`$__module__.$s`](@ref). """ esc(quote $Unitful.abbr(::$Dimension{$x}) = $abbr @@ -125,20 +131,25 @@ macro derived_dimension(name, dims, autodocs=false) name_links = __module__ == Unitful ? "[`Unitful.Quantity`](@ref), [`Unitful.Level`](@ref)" : "`Unitful.Quantity`, `Unitful.Level`" unit_links = __module__ == Unitful ? "[`Unitful.Units`](@ref)" : "`Unitful.Units`" funit_links = __module__ == Unitful ? "[`Unitful.FreeUnits`](@ref)" : "`Unitful.FreeUnits`" - name_doc = """ - $__module__.$name{T, U} - \nA supertype for quantities and levels of dimension `$dims` with a value of type `T` and - units `U`. - \nSee also: $name_links. - """ - unit_doc = """ - $__module__.$uname{U} - \nA supertype for units of dimension `$dims`. Equivalent to `Unitful.Units{U, $dims}`. - \nSee also: $unit_links. - """ + name_doc = """ + $__module__.$name{T, U} + + A supertype for quantities and levels of dimension `$dims` with a value of type `T` and + units `U`. + + See also: $name_links. + """ + unit_doc = """ + $__module__.$uname{U} + + A supertype for units of dimension `$dims`. Equivalent to `Unitful.Units{U, $dims}`. + + See also: $unit_links. + """ funit_doc = """ $__module__.$funame{U} - \nA supertype for $funit_links of dimension `$dims`. Equivalent to + + A supertype for $funit_links of dimension `$dims`. Equivalent to `Unitful.FreeUnits{U, $dims}`. """ esc(quote @@ -312,8 +323,10 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) isbase = k==0 docstring1 = """ $__module__.$s - \nA prefixed unit, equal to 10^$k $symb. - \nDimension: """ + + A prefixed unit, equal to 10^$k $symb. + + Dimension: """ docstring2 = "\n\nSee also: [`$__module__.$symb`](@ref)." ea = quote $(basefactors_expr(__module__, n, basefactor)) diff --git a/test/runtests.jl b/test/runtests.jl index df09fe0f..4e2a7cad 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1814,36 +1814,79 @@ end @test string(@doc DocUnits.dRefFoo) == "refunit docs\n" @test string(@doc DocUnits.dFoo) == "unit docs\n" @test string(@doc DocUnits.DocDimension) == """ - ```\n$(@__MODULE__).DocUnits.DocDimension{T, U}\n```\n - A supertype for quantities and levels of dimension [`$(@__MODULE__).DocUnits.๐ƒ`](@ref) with a value of type `T` and units `U`.\n - See also: [`$(@__MODULE__).DocUnits.๐ƒ`](@ref), `Unitful.Quantity`, `Unitful.Level`.\n""" + ``` + $(@__MODULE__).DocUnits.DocDimension{T, U} + ``` + + A supertype for quantities and levels of dimension [`$(@__MODULE__).DocUnits.๐ƒ`](@ref) with a value of type `T` and units `U`. + + See also: [`$(@__MODULE__).DocUnits.๐ƒ`](@ref), `Unitful.Quantity`, `Unitful.Level`. + """ @test string(@doc DocUnits.DocDimensionUnits) == """ - ```\n$(@__MODULE__).DocUnits.DocDimensionUnits{U}\n```\n - A supertype for units of dimension [`$(@__MODULE__).DocUnits.๐ƒ`](@ref). Equivalent to `Unitful.Units{U, $(@__MODULE__).DocUnits.๐ƒ}`.\n - See also: [`$(@__MODULE__).DocUnits.๐ƒ`](@ref), `Unitful.Units`.\n""" + ``` + $(@__MODULE__).DocUnits.DocDimensionUnits{U} + ``` + + A supertype for units of dimension [`$(@__MODULE__).DocUnits.๐ƒ`](@ref). Equivalent to `Unitful.Units{U, $(@__MODULE__).DocUnits.๐ƒ}`. + + See also: [`$(@__MODULE__).DocUnits.๐ƒ`](@ref), `Unitful.Units`. + """ @test string(@doc DocUnits.DocDimensionFreeUnits) == """ - ```\n$(@__MODULE__).DocUnits.DocDimensionFreeUnits{U}\n```\n - A supertype for `Unitful.FreeUnits` of dimension [`$(@__MODULE__).DocUnits.๐ƒ`](@ref). Equivalent to `Unitful.FreeUnits{U, $(@__MODULE__).DocUnits.๐ƒ}`.\n - See also: [`$(@__MODULE__).DocUnits.๐ƒ`](@ref).\n""" + ``` + $(@__MODULE__).DocUnits.DocDimensionFreeUnits{U} + ``` + + A supertype for `Unitful.FreeUnits` of dimension [`$(@__MODULE__).DocUnits.๐ƒ`](@ref). Equivalent to `Unitful.FreeUnits{U, $(@__MODULE__).DocUnits.๐ƒ}`. + + See also: [`$(@__MODULE__).DocUnits.๐ƒ`](@ref). + """ @test string(@doc DocUnits.DerivedDocDimension) == """ - ```\n$(@__MODULE__).DocUnits.DerivedDocDimension{T, U}\n```\n - A supertype for quantities and levels of dimension `๐ƒ * ๐‹` with a value of type `T` and units `U`.\n - See also: `Unitful.Quantity`, `Unitful.Level`.\n""" + ``` + $(@__MODULE__).DocUnits.DerivedDocDimension{T, U} + ``` + + A supertype for quantities and levels of dimension `๐ƒ * ๐‹` with a value of type `T` and units `U`. + + See also: `Unitful.Quantity`, `Unitful.Level`. + """ @test string(@doc DocUnits.DerivedDocDimensionUnits) == """ - ```\n$(@__MODULE__).DocUnits.DerivedDocDimensionUnits{U}\n```\n - A supertype for units of dimension `๐ƒ * ๐‹`. Equivalent to `Unitful.Units{U, ๐ƒ * ๐‹}`.\n - See also: `Unitful.Units`.\n""" + ``` + $(@__MODULE__).DocUnits.DerivedDocDimensionUnits{U} + ``` + + A supertype for units of dimension `๐ƒ * ๐‹`. Equivalent to `Unitful.Units{U, ๐ƒ * ๐‹}`. + + See also: `Unitful.Units`. + """ @test string(@doc DocUnits.DerivedDocDimensionFreeUnits) == """ - ```\n$(@__MODULE__).DocUnits.DerivedDocDimensionFreeUnits{U}\n```\n - A supertype for `Unitful.FreeUnits` of dimension `๐ƒ * ๐‹`. Equivalent to `Unitful.FreeUnits{U, ๐ƒ * ๐‹}`.\n""" + ``` + $(@__MODULE__).DocUnits.DerivedDocDimensionFreeUnits{U} + ``` + + A supertype for `Unitful.FreeUnits` of dimension `๐ƒ * ๐‹`. Equivalent to `Unitful.FreeUnits{U, ๐ƒ * ๐‹}`. + """ @test string(@doc DocUnits.kdFoo) == """ - ```\n$(@__MODULE__).DocUnits.kdFoo\n```\n - A prefixed unit, equal to 10^3 dFoo.\n\nDimension: ๐ƒ ๐‹\n - See also: [`$(@__MODULE__).DocUnits.dFoo`](@ref).\n""" + ``` + $(@__MODULE__).DocUnits.kdFoo + ``` + + A prefixed unit, equal to 10^3 dFoo. + + Dimension: ๐ƒ ๐‹ + + See also: [`$(@__MODULE__).DocUnits.dFoo`](@ref). + """ @test string(@doc DocUnits.kdRefFoo) == """ - ```\n$(@__MODULE__).DocUnits.kdRefFoo\n```\n - A prefixed unit, equal to 10^3 dRefFoo.\n\nDimension: ๐ƒ\n - See also: [`$(@__MODULE__).DocUnits.dRefFoo`](@ref).\n""" + ``` + $(@__MODULE__).DocUnits.kdRefFoo + ``` + + A prefixed unit, equal to 10^3 dRefFoo. + + Dimension: ๐ƒ + + See also: [`$(@__MODULE__).DocUnits.dRefFoo`](@ref). + """ end # Test precompiled Unitful extension modules From 4de04116e8ee5b36f236052d880935dc38317bad Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Mon, 18 Oct 2021 14:35:39 -0500 Subject: [PATCH 41/43] Apply suggestions from code review Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/pkgdefaults.jl | 6 +++++- src/user.jl | 48 ++++++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/pkgdefaults.jl b/src/pkgdefaults.jl index 73e93f6b..09a38d47 100644 --- a/src/pkgdefaults.jl +++ b/src/pkgdefaults.jl @@ -308,7 +308,7 @@ for p in (:y, :z, :a, :f, :p, :n, :ฮผ, :ยต, :m, :c, :d, end @doc @doc(L) l for (k,v) in prefixdict - if (k!=0) + if k != 0 sym_L = Symbol(v,:L) sym_l = Symbol(v,:l) docstring = """ @@ -373,12 +373,14 @@ const q = 1.602_176_634e-19*C # CODATA 2018; `e` means 2.718... " Unitful.c0 \nA quantity representing the speed of light in a vacuum, defined as exactly 2.997,924,58 ร— 10^8 m/s. +\n`Unitful.c0` is a quantity (with units `m/s`) whereas [`Unitful.c`](@ref) is a unit equal to `c0`. \nDimension: ๐‹ ๐“^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const c0 = 299_792_458*m/s # exact " Unitful.c \nThe speed of light in a vacuum, a unit of speed, defined as exactly 2.997,924,58 ร— 10^8 m/s. +\n[`Unitful.c0`](@ref) is a quantity (with units `m/s`) whereas `Unitful.c` is a unit equal to `c0`. \nDimension: ๐‹ ๐“^-1. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit c "c" SpeedOfLight 1c0 false @@ -409,6 +411,7 @@ const G = 6.674_30e-11*m^3/kg/s^2 # (15) gravitational constant " Unitful.gn \nA quantity representing the nominal acceleration due to gravity in a vacuum near the surface of the earth, defined by standard to be exactly 9.806,65 m / s^2. +\n`Unitful.gn` is a quantity (with units `m/s^2`) whereas [`Unitful.ge`](@ref) is a unit equal to `gn`. \nDimension: ๐‹ ๐“^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." const gn = 9.80665*m/s^2 # exact, standard acceleration of gravity @@ -495,6 +498,7 @@ mass of an unbound neutral atom of carbon-12, equal to 1.660,539,066,60 ร— 10^-2 " Unitful.ge \nThe nominal acceleration due to gravity in a vacuum near the surface of the earth, a unit of acceleration, defined by standard to be exactly 9.806,65 m / s^2. +\n[`Unitful.gn`](@ref) is a quantity (with units `m/s^2`) whereas `Unitful.ge` is a unit equal to `gn`. \nDimension: ๐‹ ๐“^-2. \nSee also: [`Unitful.m`](@ref), [`Unitful.s`](@ref)." @unit ge "ge" EarthGravity gn false diff --git a/src/user.jl b/src/user.jl index b77c28b3..b9d59b7d 100644 --- a/src/user.jl +++ b/src/user.jl @@ -46,7 +46,9 @@ dispatching on `FreeUnits` with length dimensions. The aliases are not exported. If `autodocs == true`, docstrings will be automatically generated for these aliases. !!! compat "Unitful 1.10" - The `autodocs` argument requires Unitful 1.10 or later. + Documenting the resulting dimension symbol by adding a docstring before the `@dimension` + call requires Unitful 1.10 or later. The `autodocs` argument also requires Unitful 1.10 + or later. Finally, if you define new dimensions with [`@dimension`](@ref) you will need to specify a preferred unit for that dimension with [`Unitful.preferunits`](@ref), @@ -182,7 +184,8 @@ of the reference unit. If `autodocs == true`, autogenerated docstrings for SI-prefixed units will be added. This option has no effect when 'autodocs == false'. !!! compat "Unitful 1.10" - The `autodocs` argument requires Unitful 1.10 or later. + Documenting the resulting unit by adding a docstring before the `@refunit` call requires + Unitful 1.10 or later. The `autodocs` argument also requires Unitful 1.10 or later. In principle, users can use this macro, but it probably does not make much sense to do so. If you define a new (probably unphysical) dimension using @@ -236,7 +239,8 @@ If `autodocs == true`, autogenerated docstrings for SI-prefixed units will be ad This option has no effect when `autodocs == false`. !!! compat "Unitful 1.10" - The `autodocs` argument requires Unitful 1.10 or later. + Documenting the resulting unit by adding a docstring before the `@unit` call requires + Unitful 1.10 or later. The `autodocs` argument also requires Unitful 1.10 or later. Returns the [`Unitful.FreeUnits`](@ref) object to which `symb` is bound. @@ -308,7 +312,9 @@ will define units for each possible SI power-of-ten prefix on that unit. If `autodocs == true`, it will automatically generate docstrings for these units. !!! compat "Unitful 1.10" - The `autodocs` argument requires Unitful 1.10 or later. + Documenting the resulting unit by adding a docstring before the `@prefixed_unit_symbols` + call requires Unitful 1.10 or later. The `autodocs` argument also requires Unitful 1.10 + or later. Example: `@prefixed_unit_symbols m Meter ๐‹ (1.0,1) true` results in `nm`, `cm`, `m`, `km`, ... all getting defined in the calling namespace, with docstrings automatically defined for SI-prefixed units. @@ -320,21 +326,25 @@ macro prefixed_unit_symbols(symb,name,user_dimension,basefactor,autodocs=false) for (k,v) in prefixdict s = Symbol(v,symb) u = :($Unit{$n, $user_dimension}($k,1//1)) - isbase = k==0 - docstring1 = """ - $__module__.$s - - A prefixed unit, equal to 10^$k $symb. - - Dimension: """ - docstring2 = "\n\nSee also: [`$__module__.$symb`](@ref)." - ea = quote - $(basefactors_expr(__module__, n, basefactor)) - const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() - if $isbase - Base.@__doc__ $s - elseif $autodocs - @doc $docstring1*string($user_dimension)*$docstring2 $s + if k == 0 + ea = quote + $(basefactors_expr(__module__, n, basefactor)) + Base.@__doc__ const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() + end + else + docstring1 = """ + $__module__.$s + + A prefixed unit, equal to 10^$k $symb. + + Dimension: """ + docstring2 = "\n\nSee also: [`$__module__.$symb`](@ref)." + ea = quote + $(basefactors_expr(__module__, n, basefactor)) + const global $s = $FreeUnits{($u,), $dimension($u), $nothing}() + if $autodocs + @doc $docstring1*string($user_dimension)*$docstring2 $s + end end end push!(expr.args, ea) From 49e81e54f9ab9f741dd201494d1a9d9262ee1b4a Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Mon, 18 Oct 2021 14:41:57 -0500 Subject: [PATCH 42/43] More documentation changes from code review Also removed documentation ability for logunit and logscale (as these should be another pull request) --- src/user.jl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/user.jl b/src/user.jl index b9d59b7d..c33e158d 100644 --- a/src/user.jl +++ b/src/user.jl @@ -282,6 +282,10 @@ end Macro for easily defining affine units. `offset` gives the zero of the relative scale in terms of an absolute scale; the scaling is the same as the absolute scale. Example: `@affineunit ยฐC "ยฐC" (27315//100)K` is used internally to define degrees Celsius. + +!!! compat "Unitful 1.10" + Documenting the resulting unit by adding a docstring before the `@affineunit` call + requires Unitful 1.10 or later. """ macro affineunit(symb, abbr, offset) s = Symbol(symb) @@ -366,6 +370,10 @@ end Not called directly by the user. Given a unit symbol and a unit's name, will define units without SI power-of-ten prefixes. +!!! compat "Unitful 1.10" + Documenting the resulting unit by adding a docstring before the `@unit_symbols` call + requires Unitful 1.10 or later. + Example: `@unit_symbols ft Foot ๐‹` results in `ft` getting defined but not `kft`. """ macro unit_symbols(symb,name,user_dimension,basefactor) @@ -498,7 +506,7 @@ macro logscale(symb,abbr,name,base,prefactor,irp) const global $(esc(name)) = LogInfo{$(QuoteNode(name)), $base, $prefactor} $Unitful.isrootpower(::Type{$(esc(name))}) = $irp - Base.@__doc__ const global $(esc(symb)) = MixedUnits{Gain{$(esc(name)), :?}}() + const global $(esc(symb)) = MixedUnits{Gain{$(esc(name)), :?}}() const global $(esc(Symbol(symb,"_rp"))) = MixedUnits{Gain{$(esc(name)), :rp}}() const global $(esc(Symbol(symb,"_p"))) = MixedUnits{Gain{$(esc(name)), :p}}() @@ -559,7 +567,7 @@ Defines a logarithmic unit. For examples see `src/pkgdefaults.jl`. macro logunit(symb, abbr, logscale, reflevel) quote $Unitful.abbr(::Level{$(esc(logscale)), $(esc(reflevel))}) = $abbr - Base.@__doc__ const global $(esc(symb)) = + const global $(esc(symb)) = MixedUnits{Level{$(esc(logscale)), $(esc(reflevel))}}() end end From 4787813bf6137471352c1dd7dd8fac531a3f61ca Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Tue, 19 Oct 2021 12:26:35 -0500 Subject: [PATCH 43/43] Apply suggestions from code review Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com> --- src/user.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/user.jl b/src/user.jl index c33e158d..e91d8346 100644 --- a/src/user.jl +++ b/src/user.jl @@ -181,7 +181,7 @@ displayed in an abbreviated format. If `tf == true`, this macro generates symbol for every power of ten of the unit, using the standard SI prefixes. A `dimension` must be given ([`Unitful.Dimensions`](@ref) object) that specifies the dimension of the reference unit. If `autodocs == true`, autogenerated docstrings for -SI-prefixed units will be added. This option has no effect when 'autodocs == false'. +SI-prefixed units will be added. This option has no effect when 'tf == false'. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@refunit` call requires @@ -236,7 +236,7 @@ Define a unit. Rather than specifying a dimension like in [`@refunit`](@ref), `equals` should be a [`Unitful.Quantity`](@ref) equal to one of the unit being defined. If `tf == true`, symbols will be made for each power-of-ten prefix. If `autodocs == true`, autogenerated docstrings for SI-prefixed units will be added. -This option has no effect when `autodocs == false`. +This option has no effect when `tf == false`. !!! compat "Unitful 1.10" Documenting the resulting unit by adding a docstring before the `@unit` call requires