Skip to content

Commit 40bdee7

Browse files
committed
up doc
1 parent 07939ef commit 40bdee7

16 files changed

+89
-69
lines changed

.github/ISSUE_TEMPLATE/blank-issue.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Blank issue
33
about: Blank template for general issue
4-
title: "[General] title"
4+
title: "[General] "
55
labels: ''
66
assignees: ocots
77

.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Bug report
33
about: Create a bug report to help us improve
4-
title: "[Bug] title"
4+
title: "[Bug] "
55
labels: bug
66
assignees: ocots
77

.github/ISSUE_TEMPLATE/developers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: 'Developers '
33
about: Suggest internal modifications
4-
title: "[Dev] title"
4+
title: "[Dev] "
55
labels: internal dev
66
assignees: ocots
77

.github/ISSUE_TEMPLATE/documentation-suggestion.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Documentation suggestion
33
about: Suggest improvements or additions to the documentation
4-
title: "[Doc] title"
4+
title: "[Doc] "
55
labels: documentation
66
assignees: ocots
77

.github/ISSUE_TEMPLATE/feature_request.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: "[Feature] title"
4+
title: "[Feature] "
55
labels: enhancement
66
assignees: ocots
77

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CTBase"
22
uuid = "54762871-cc72-4466-b8e8-f6c8b58076cd"
33
authors = ["Olivier Cots <olivier.cots@irit.fr>", "Jean-Baptiste Caillau <caillau@univ-cotedazur.fr>"]
4-
version = "0.15.0"
4+
version = "0.15.1"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"

docs/make.jl

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ using Documenter
22
using CTBase
33
using DocumenterMermaid
44

5+
# to add docstrings from external packages
6+
Modules = [Base]
7+
for Module in Modules
8+
isnothing(DocMeta.getdocmeta(Module, :DocTestSetup)) &&
9+
DocMeta.setdocmeta!(Module, :DocTestSetup, :(using $Module); recursive=true)
10+
end
11+
512
repo_url = "github.com/control-toolbox/CTBase.jl"
613

714
makedocs(;
@@ -16,7 +23,7 @@ makedocs(;
1623
asset("https://control-toolbox.org/assets/js/documentation.js"),
1724
],
1825
),
19-
pages=["Introduction" => "index.md", "API" => "api.md", "Developers" => "dev.md"],
26+
pages=["Introduction" => "index.md", "Developers" => "dev.md"],
2027
checkdocs=:none,
2128
)
2229

docs/src/api.md

-21
This file was deleted.

docs/src/dev.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Private functions
22

33
```@meta
4-
CollapsedDocStrings = true
4+
CollapsedDocStrings = false
55
```
66

77
## Index
88

99
```@index
1010
Pages = ["dev.md"]
11-
Modules = [CTBase]
11+
Modules = [CTBase, Base]
1212
Order = [:module, :constant, :type, :function, :macro]
1313
```
1414

1515
## Documentation
1616

1717
```@autodocs
1818
Modules = [CTBase]
19-
Order = [:module, :constant, :type, :function, :macro]
19+
Order = [:type, :module, :constant, :type, :function, :macro]
2020
Public = false
21-
```
21+
```

docs/src/index.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,22 @@ The `CTBase.jl` package is part of the [control-toolbox ecosystem](https://githu
88

99
```mermaid
1010
flowchart TD
11-
O(<a href='https://control-toolbox.org/OptimalControl.jl/stable/'>OptimalControl</a>) --> B(<a href='https://control-toolbox.org/OptimalControl.jl/stable/api-ctbase.html'>CTBase</a>)
12-
O --> D(<a href='https://control-toolbox.org/OptimalControl.jl/stable/api-ctdirect.html'>CTDirect</a>)
13-
O --> F(<a href='https://control-toolbox.org/OptimalControl.jl/stable/api-ctflows.html'>CTFlows</a>)
11+
B(<a href='https://control-toolbox.org/OptimalControl.jl/stable/api-ctbase.html'>CTBase</a>)
12+
M(<a href='https://control-toolbox.org/OptimalControl.jl/stable/api-ctmodels.html'>CTModels</a>)
13+
P(<a href='https://control-toolbox.org/OptimalControl.jl/stable/api-ctparser.html'>CTParser</a>)
14+
O(<a href='https://control-toolbox.org/OptimalControl.jl/stable/api-optimalcontrol.html'>OptimalControl</a>)
15+
D(<a href='https://control-toolbox.org/OptimalControl.jl/stable/api-ctdirect.html'>CTDirect</a>)
16+
F(<a href='https://control-toolbox.org/OptimalControl.jl/stable/api-ctflows.html'>CTFlows</a>)
17+
O --> D
18+
O --> M
19+
O --> F
20+
O --> P
21+
F --> M
22+
O --> B
1423
F --> B
1524
D --> B
25+
D --> M
26+
P --> B
27+
M --> B
1628
style B fill:#FBF275
17-
```
29+
```

src/CTBase.jl

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
Lists all the imported modules and packages:
55
66
$(IMPORTS)
7-
8-
List of all the exported names:
9-
10-
$(EXPORTS)
117
"""
128
module CTBase
139

src/default.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
$(TYPEDSIGNATURES)
33
44
Used to set the default value of the display argument.
5-
The default value is `true`, which means that the output is printed during resolution.
5+
The default value is `true`, which means that the output is printed during execution.
66
"""
77
__display()::Bool = true

src/description.jl

+27-16
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@ julia> descriptions[1]
6767
(:a,)
6868
```
6969
"""
70-
add(x::Tuple{}, y::Description)::Tuple{Vararg{Description}} = (y,)
70+
add(::Tuple{}, y::Description)::Tuple{Vararg{Description}} = (y,)
7171

7272
"""
7373
$(TYPEDSIGNATURES)
7474
75-
Concatenate the description `y` to the tuple of descriptions `x` if `x` does not contain `y`
76-
and return the new tuple of descriptions. Throw an error if the description `y` is already contained in `x`.
75+
Add the description `y` to the tuple of descriptions `x` if `x` does not contain `y`
76+
and return the new tuple of descriptions.
77+
78+
Throw an exception (IncorrectArgument) if the description `y` is already contained in `x`.
7779
7880
# Example
7981
@@ -99,35 +101,44 @@ end
99101
"""
100102
$(TYPEDSIGNATURES)
101103
102-
Return a complete description from an incomplete description `desc` and
103-
a list of complete descriptions `desc_list`. If several complete descriptions are possible,
104-
then the first one is returned.
104+
Return one description from a list of Symbols `list` and a set of descriptions `D`.
105+
If multiple descriptions are possible, then the first one is selected.
106+
107+
If the list is not contained in any of the descriptions, then an exception is thrown.
105108
106109
# Example
107110
108111
```@example
109-
julia> desc_list = ((:a, :b), (:b, :c), (:a, :c))
112+
julia> D = ((:a, :b), (:a, :b, :c), (:b, :c), (:a, :c))
110113
(:a, :b)
111114
(:b, :c)
112115
(:a, :c)
113-
julia> getFullDescription((:a,), desc_list)
116+
julia> complete(:a; descriptions=D)
114117
(:a, :b)
118+
julia> complete(:a, :c; descriptions=D)
119+
(:a, :b, :c)
120+
julia> complete((:a, :c); descriptions=D)
121+
(:a, :b, :c)
122+
julia> complete(:f; descriptions=D)
123+
ERROR: AmbiguousDescription: the description (:f,) is ambiguous / incorrect
115124
```
116125
"""
117-
function getFullDescription(
118-
desc::Description, desc_list::Tuple{Vararg{Description}}
119-
)::Description
120-
n = size(desc_list, 1)
126+
function complete(list::Symbol...; descriptions::Tuple{Vararg{Description}})::Description
127+
n = size(descriptions, 1)
121128
table = zeros(Int8, n, 2)
122129
for i in range(1, n)
123-
table[i, 1] = size(desc desc_list[i], 1)
124-
table[i, 2] = desc desc_list[i] ? 1 : 0
130+
table[i, 1] = size(list descriptions[i], 1)
131+
table[i, 2] = list descriptions[i] ? 1 : 0
125132
end
126133
if maximum(table[:, 2]) == 0
127-
throw(AmbiguousDescription(desc))
134+
throw(AmbiguousDescription(list))
128135
end
129136
# argmax : Return the index or key of the maximal element in a collection.
130-
return desc_list[argmax(table[:, 1])]
137+
return descriptions[argmax(table[:, 1])]
138+
end
139+
140+
function complete(list::Tuple{DescVarArg}; descriptions::Tuple{Vararg{Description}})::Description
141+
return complete(list..., descriptions=descriptions)
131142
end
132143

133144
"""

src/exception.jl

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ Exception thrown when the description is ambiguous / incorrect.
1515
**Fields**
1616
1717
$(TYPEDFIELDS)
18+
19+
**Example**
20+
21+
```@example
22+
julia> complete(:f; descriptions=((:a, :b), (:a, :b, :c))
23+
ERROR: AmbiguousDescription: the description (:f,) is ambiguous / incorrect
24+
```
1825
"""
1926
struct AmbiguousDescription <: CTException
2027
var::Tuple{Vararg{Symbol}}

src/utils.jl

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
$(TYPEDSIGNATURES)
33
44
Return `i` ∈ [0, 9] as a subscript.
5+
6+
If `i` is not in the range, an exception is thrown.
57
"""
68
function ctindice(i::Int)::Char
79
if i < 0 || i > 9
@@ -14,6 +16,8 @@ end
1416
$(TYPEDSIGNATURES)
1517
1618
Return `i` > 0 as a subscript.
19+
20+
If `i` is not in the range, an exception is thrown.
1721
"""
1822
function ctindices(i::Int)::String
1923
if i < 0
@@ -30,6 +34,8 @@ end
3034
$(TYPEDSIGNATURES)
3135
3236
Return `i` ∈ [0, 9] as an upperscript.
37+
38+
If `i` is not in the range, an exception is thrown.
3339
"""
3440
function ctupperscript(i::Int)::Char
3541
if i < 0 || i > 9
@@ -56,6 +62,8 @@ end
5662
$(TYPEDSIGNATURES)
5763
5864
Return `i` > 0 as an upperscript.
65+
66+
If `i` is not in the range, an exception is thrown.
5967
"""
6068
function ctupperscripts(i::Int)::String
6169
if i < 0

test/test_description.jl

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ function test_description()
1616
algorithmes = CTBase.add(algorithmes, (:descent, :gradient, :backtracking))
1717
algorithmes = CTBase.add(algorithmes, (:descent, :gradient, :fixedstep))
1818

19-
@test CTBase.getFullDescription((:descent,), algorithmes) == (:descent, :bfgs, :bissection)
20-
@test CTBase.getFullDescription((:bfgs,), algorithmes) == (:descent, :bfgs, :bissection)
21-
@test CTBase.getFullDescription((:bissection,), algorithmes) == (:descent, :bfgs, :bissection)
22-
@test CTBase.getFullDescription((:backtracking,), algorithmes) == (:descent, :bfgs, :backtracking)
23-
@test CTBase.getFullDescription((:fixedstep,), algorithmes) == (:descent, :bfgs, :fixedstep)
24-
@test CTBase.getFullDescription((:fixedstep, :gradient), algorithmes) == (:descent, :gradient, :fixedstep)
19+
@test CTBase.complete((:descent,); descriptions=algorithmes) == (:descent, :bfgs, :bissection)
20+
@test CTBase.complete((:bfgs,); descriptions=algorithmes) == (:descent, :bfgs, :bissection)
21+
@test CTBase.complete((:bissection,); descriptions=algorithmes) == (:descent, :bfgs, :bissection)
22+
@test CTBase.complete((:backtracking,); descriptions=algorithmes) == (:descent, :bfgs, :backtracking)
23+
@test CTBase.complete((:fixedstep,); descriptions=algorithmes) == (:descent, :bfgs, :fixedstep)
24+
@test CTBase.complete((:fixedstep, :gradient); descriptions=algorithmes) == (:descent, :gradient, :fixedstep)
2525

2626
# incorrect description
27-
@test_throws CTBase.AmbiguousDescription CTBase.getFullDescription((:ttt,), algorithmes)
28-
@test_throws CTBase.AmbiguousDescription CTBase.getFullDescription((:descent, :ttt), algorithmes)
27+
@test_throws CTBase.AmbiguousDescription CTBase.complete((:ttt,); descriptions=algorithmes)
28+
@test_throws CTBase.AmbiguousDescription CTBase.complete((:descent, :ttt); descriptions=algorithmes)
2929

3030
# diff
3131
x = (:a, :b, :c)
@@ -37,16 +37,16 @@ function test_description()
3737
algorithmes = ()
3838
algorithmes = CTBase.add(algorithmes, (:a, :b, :c))
3939
algorithmes = CTBase.add(algorithmes, (:a, :b, :c, :d))
40-
@test CTBase.getFullDescription((:a, :b), algorithmes) == (:a, :b, :c)
41-
@test CTBase.getFullDescription((:a, :b, :c, :d), algorithmes) == (:a, :b, :c, :d)
40+
@test CTBase.complete((:a, :b); descriptions=algorithmes) == (:a, :b, :c)
41+
@test CTBase.complete((:a, :b, :c, :d); descriptions=algorithmes) == (:a, :b, :c, :d)
4242

4343
# inclusion and different sizes - switch ordering
4444
# priority to the first with max shared elements
4545
algorithmes = ()
4646
algorithmes = CTBase.add(algorithmes, (:a, :b, :c, :d))
4747
algorithmes = CTBase.add(algorithmes, (:a, :b, :c))
48-
@test CTBase.getFullDescription((:a, :b), algorithmes) == (:a, :b, :c, :d)
49-
@test CTBase.getFullDescription((:a, :b, :c, :d), algorithmes) == (:a, :b, :c, :d)
48+
@test CTBase.complete((:a, :b); descriptions=algorithmes) == (:a, :b, :c, :d)
49+
@test CTBase.complete((:a, :b, :c, :d); descriptions=algorithmes) == (:a, :b, :c, :d)
5050

5151
# CTBase.add a description already in the list
5252
algorithmes = ()

0 commit comments

Comments
 (0)