Skip to content

Commit eb541ed

Browse files
committed
More documentation
1 parent 755e497 commit eb541ed

File tree

4 files changed

+86
-12
lines changed

4 files changed

+86
-12
lines changed

docs/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3-
DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"

docs/make.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using DynamicQuantities
2+
import DynamicQuantities.Units
23
using Documenter
34

45
DocMeta.setdocmeta!(DynamicQuantities, :DocTestSetup, :(using DynamicQuantities); recursive=true)
@@ -26,7 +27,7 @@ open(dirname(@__FILE__) * "/src/index.md", "w") do io
2627
end
2728

2829
makedocs(;
29-
modules=[DynamicQuantities],
30+
modules=[DynamicQuantities, DynamicQuantities.Units],
3031
authors="MilesCranmer <[email protected]> and contributors",
3132
repo="https://github.com/SymbolicML/DynamicQuantities.jl/blob/{commit}{path}#{line}",
3233
sitename="DynamicQuantities.jl",

docs/src/api.md

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,87 @@
1-
```@meta
2-
CurrentModule = DynamicQuantities
1+
# Usage
2+
3+
## Types
4+
5+
```@docs
6+
Quantity
7+
Dimensions
38
```
49

5-
# API Reference
10+
## Utilities
11+
12+
The two main general utilities for working
13+
with quantities are `ustrip` and `dimension`:
614

7-
API Reference for [DynamicQuantities](https://github.com/SymbolicML/DynamicQuantities.jl).
15+
```@docs
16+
ustrip
17+
dimension
18+
```
19+
20+
Utility functions to extract specific dimensions are as follows:
821

9-
```@index
22+
```@docs
23+
ulength
24+
umass
25+
utime
26+
ucurrent
27+
utemperature
28+
uluminosity
29+
uamount
1030
```
1131

1232
```@autodocs
1333
Modules = [DynamicQuantities]
14-
Order = [:type, :function]
15-
```
34+
Pages = ["utils.jl"]
35+
Filter = t -> !(t in [ustrip, dimension, ulength, umass, utime, ucurrent, utemperature, uluminosity, uamount])
36+
```
37+
38+
## Units
39+
40+
The two main functions for working with units are `uparse` and `u_str`:
41+
42+
```@docs
43+
@u_str
44+
uparse
45+
```
46+
47+
The base SI units are as follows.
48+
Instead of calling directly, it is recommended to access them via
49+
the `@u_str` macro, which evaluates the expression
50+
in a namespace with all the units available.
51+
52+
```@docs
53+
Units.m
54+
Units.g
55+
Units.s
56+
Units.A
57+
Units.K
58+
Units.cd
59+
Units.mol
60+
```
61+
62+
Several derived SI units are available as well:
63+
64+
```@docs
65+
Units.Hz
66+
Units.N
67+
Units.Pa
68+
Units.J
69+
Units.W
70+
Units.C
71+
Units.V
72+
Units.F
73+
Units.Ω
74+
Units.T
75+
Units.L
76+
Units.bar
77+
```
78+
79+
## Internals
80+
81+
### FixedRational
82+
83+
```@docs
84+
DynamicQuantities.FixedRational
85+
DynamicQuantities.denom
86+
```
87+

src/types.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ const DEFAULT_DIM_TYPE = FixedRational{Int32, 2^4 * 3^2 * 5^2 * 7}
22
const DEFAULT_VALUE_TYPE = Float64
33

44
"""
5-
Dimensions
5+
Dimensions{R}
66
77
A type representing the dimensions of a quantity, with each
88
field giving the power of the corresponding dimension. For
99
example, the dimensions of velocity are `Dimensions(length=1, time=-1)`.
10+
Each of the 7 dimensions are stored using the type `R`,
11+
which is by default a rational number.
1012
1113
# Fields
1214
@@ -56,9 +58,9 @@ const DIMENSION_SYNONYMS = (:m, :kg, :s, :A, :K, :cd, :mol)
5658
const SYNONYM_MAPPING = NamedTuple(DIMENSION_NAMES .=> DIMENSION_SYNONYMS)
5759

5860
"""
59-
Quantity{T}
61+
Quantity{T,R}
6062
61-
Physical quantity with value `value` of type `T` and dimensions `dimensions`.
63+
Physical quantity with value `value` of type `T` and dimensions `dimensions` of type `Dimensions{R}`.
6264
For example, the velocity of an object with mass 1 kg and velocity
6365
2 m/s is `Quantity(2, mass=1, length=1, time=-1)`.
6466
You should access these fields with `ustrip(q)`, and `dimensions(q)`.

0 commit comments

Comments
 (0)