Skip to content

Commit 8d6bc73

Browse files
committed
Convert metadata.md doctests to @repl blocks
This makes the documentation easier to maintain.
1 parent e4d475d commit 8d6bc73

File tree

1 file changed

+37
-85
lines changed

1 file changed

+37
-85
lines changed

docs/src/metadata.md

Lines changed: 37 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -18,65 +18,43 @@ meta(meta-geometry)
1818

1919
### Examples
2020

21-
```jldoctest meta
22-
julia> using GeometryBasics
23-
24-
julia> p1 = Point(2.2, 3.6)
25-
2-element Point2{Float64} with indices SOneTo(2):
26-
2.2
27-
3.6
28-
29-
julia> poi = meta(p1, city="Abuja", rainfall=1221.2)
30-
2-element PointMeta{2, Float64, Point2{Float64}, (:city, :rainfall), Tuple{String, Float64}} with indices SOneTo(2):
31-
2.2
32-
3.6
21+
```@repl meta
22+
using GeometryBasics
23+
p1 = Point(2.2, 3.6)
24+
poi = meta(p1, city="Abuja", rainfall=1221.2)
3325
```
3426

3527
Metadata is stored in a NamedTuple and can be retrieved as such:
3628

37-
```jldoctest meta
38-
julia> meta(poi)
39-
(city = "Abuja", rainfall = 1221.2)
29+
```@repl meta
30+
meta(poi)
4031
```
4132

4233
Specific metadata attributes can be directly retrieved:
4334

44-
```jldoctest meta
45-
julia> poi.rainfall
46-
1221.2
47-
48-
julia> metafree(poi)
49-
2-element Point2{Float64} with indices SOneTo(2):
50-
2.2
51-
3.6
35+
```@repl meta
36+
poi.rainfall
37+
metafree(poi)
5238
```
5339

5440
Metatypes are predefined for geometries:
5541

56-
```jldoctest meta
57-
julia> multipoi = MultiPointMeta([p1], city="Abuja", rainfall=1221.2)
58-
1-element MultiPointMeta{Point2{Float64}, MultiPoint{2, Float64, Point2{Float64}, Vector{Point2{Float64}}}, (:city, :rainfall), Tuple{String, Float64}}:
59-
[2.2, 3.6]
42+
```@repl meta
43+
multipoi = MultiPointMeta([p1], city="Abuja", rainfall=1221.2)
6044
```
6145

6246
(In the above example we have also used a geometry-specific meta method.)
6347

64-
```jldoctest meta
65-
julia> GeometryBasics.MetaType(Polygon)
66-
PolygonMeta
67-
68-
julia> GeometryBasics.MetaType(Mesh)
69-
MeshMeta
48+
```@repl meta
49+
GeometryBasics.MetaType(Polygon)
50+
GeometryBasics.MetaType(Mesh)
7051
```
7152

7253
The metageometry objects are infact composed of the original geometry types.
7354

74-
```jldoctest meta
75-
julia> GeometryBasics.MetaFree(PolygonMeta)
76-
Polygon
77-
78-
julia> GeometryBasics.MetaFree(MeshMeta)
79-
Mesh
55+
```@repl meta
56+
GeometryBasics.MetaFree(PolygonMeta)
57+
GeometryBasics.MetaFree(MeshMeta)
8058
```
8159

8260
## MetaT
@@ -103,9 +81,8 @@ For example, while a Point MetaGeometry is a `PointMeta`, the MetaT representati
10381

10482
### Examples
10583

106-
```jldoctest meta
107-
julia> MetaT(Point(1, 2), city = "Mumbai")
108-
MetaT{Point2{Int64}, (:city,), Tuple{String}}([1, 2], (city = "Mumbai",))
84+
```@repl meta
85+
MetaT(Point(1, 2), city = "Mumbai")
10986
```
11087

11188
For a tabular representation, an iterable of `MetaT` types can be passed on to a `meta_table` method.
@@ -120,75 +97,50 @@ meta_table(iter)
12097

12198
Create an array of 2 linestrings:
12299

123-
```jldoctest meta
124-
julia> ls = [LineString([Point(i, i+1), Point(i-1,i+5)]) for i in 1:2];
125-
126-
julia> coordinates.(ls)
127-
2-element Vector{Vector{Point2{Int64}}}:
128-
[[1, 2], [0, 6]]
129-
[[2, 3], [1, 7]]
100+
```@repl meta
101+
ls = [LineString([Point(i, i+1), Point(i-1,i+5)]) for i in 1:2];
102+
coordinates.(ls)
130103
```
131104

132105
Create a multi-linestring:
133106

134-
```jldoctest meta
135-
julia> mls = MultiLineString(ls);
136-
137-
julia> coordinates.(mls)
138-
2-element Vector{Vector{Point2{Int64}}}:
139-
[[1, 2], [0, 6]]
140-
[[2, 3], [1, 7]]
107+
```@repl meta
108+
mls = MultiLineString(ls);
109+
coordinates.(mls)
141110
```
142111

143112
Create a polygon:
144113

145-
```jldoctest meta
146-
julia> poly = Polygon(Point{2, Int}[(40, 40), (20, 45), (45, 30), (40, 40)]);
147-
148-
julia> coordinates(poly)
149-
4-element Vector{Point2{Int64}}:
150-
[40, 40]
151-
[20, 45]
152-
[45, 30]
153-
[40, 40]
114+
```@repl meta
115+
poly = Polygon(Point{2, Int}[(40, 40), (20, 45), (45, 30), (40, 40)]);
116+
coordinates(poly)
154117
```
155118

156119
Put all geometries into an array:
157120

158-
```jldoctest meta
159-
julia> geom = [ls..., mls, poly];
121+
```@repl meta
122+
geom = [ls..., mls, poly];
160123
```
161124

162125
Generate some random metadata:
163126

164-
```jldoctest meta
165-
julia> prop = [(country_states = "India$(i)", rainfall = (i*9)/2) for i in 1:4]
166-
4-element Vector{NamedTuple{(:country_states, :rainfall), Tuple{String, Float64}}}:
167-
(country_states = "India1", rainfall = 4.5)
168-
(country_states = "India2", rainfall = 9.0)
169-
(country_states = "India3", rainfall = 13.5)
170-
(country_states = "India4", rainfall = 18.0)
171-
172-
julia> feat = [MetaT(i, j) for (i,j) = zip(geom, prop)]; # create an array of MetaT
127+
```@repl meta
128+
prop = [(country_states = "India$(i)", rainfall = (i*9)/2) for i in 1:4]
129+
feat = [MetaT(i, j) for (i,j) = zip(geom, prop)]; # create an array of MetaT
173130
```
174131

175132
We can now generate a `StructArray` / `Table` with `meta_table`:
176133

177-
```jldoctest meta
178-
julia> sa = meta_table(feat);
134+
```@repl meta
135+
sa = meta_table(feat);
179136
```
180137

181138
The data can be accessed through `sa.main` and the metadata through
182139
`sa.country_states` and `sa.rainfall`. Here we print only the type names of the
183140
data items for brevity:
184141

185-
```jldoctest meta
186-
julia> [nameof.(typeof.(sa.main)) sa.country_states sa.rainfall]
187-
4×3 Matrix{Any}:
188-
:LineString "India1" 4.5
189-
:LineString "India2" 9.0
190-
:MultiLineString "India3" 13.5
191-
:Polygon "India4" 18.0
142+
```@repl meta
143+
[nameof.(typeof.(sa.main)) sa.country_states sa.rainfall]
192144
```
193145

194146
### Disadvantages

0 commit comments

Comments
 (0)