Skip to content

Commit c9555a7

Browse files
authored
Merge pull request #129 from knuesel/doc-fixes
Doc fixes
2 parents 20215bf + 8d6bc73 commit c9555a7

File tree

14 files changed

+220
-202
lines changed

14 files changed

+220
-202
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,18 @@ jobs:
4848
- uses: actions/checkout@v2
4949
- uses: julia-actions/setup-julia@v1
5050
with:
51-
version: '1.5'
51+
version: '1.6'
5252
- run: |
5353
julia --project=docs -e '
5454
using Pkg
5555
Pkg.develop(PackageSpec(path=pwd()))
5656
Pkg.instantiate()'
57+
- run: |
58+
julia --project=docs -e '
59+
using Documenter: doctest, DocMeta
60+
using GeometryBasics
61+
DocMeta.setdocmeta!(GeometryBasics, :DocTestSetup, :(using GeometryBasics); recursive=true)
62+
doctest(GeometryBasics)'
5763
- run: julia --project=docs docs/make.jl
5864
env:
5965
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.DS_Store
55
/Manifest.toml
66
docs/build/
7+
*~

README.md

Lines changed: 21 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,101 +2,36 @@
22
[![Build Status](https://api.travis-ci.org/JuliaGeometry/GeometryBasics.jl.svg?branch=master)](https://travis-ci.com/JuliaGeometry/GeometryBasics.jl)
33
[![Codecov](https://codecov.io/gh/JuliaGeometry/GeometryBasics.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaGeometry/GeometryBasics.jl)
44

5-
**Documentation**:
65
[![Docs - stable](https://img.shields.io/badge/docs-stable-lightgrey.svg)](http://juliageometry.github.io/GeometryBasics.jl/stable/)
7-
[![Docs - dev](https://img.shields.io/badge/docs-dev-blue.svg)](http://juliageometry.github.io/GeometryBasics.jl/dev)
6+
[![Docs - dev](https://img.shields.io/badge/docs-dev-blue.svg)](http://juliageometry.github.io/GeometryBasics.jl/dev/)
87

98
# GeometryBasics.jl
109

11-
Basic Geometry Types.
12-
This package aims to offer a standard set of Geometry types, which easily work with metadata, query frameworks on geometries and different memory layouts.
13-
The aim is to create a solid basis for Graphics/Plotting, finite elements analysis, Geo applications, and general geometry manipulations - while offering a julian API, that still allows performant C-interop.
10+
Basic geometry types.
1411

15-
This package is a replacement for the discontinued [GeometryTypes](https://github.com/JuliaGeometry/GeometryTypes.jl/).
16-
17-
## Quick start
18-
19-
```julia
20-
using GeometryBasics
21-
22-
# create some points
23-
julia> p1 = Point(3, 1)
24-
2-element Point{2,Int64} with indices SOneTo(2):
25-
3
26-
1
27-
28-
julia> p2 = Point(1, 3);
29-
30-
julia> p3 = Point(4, 4);
31-
32-
# geometries can carry metadata
33-
julia> poi = meta(p1, city="Abuja", rainfall=1221.2)
34-
2-element PointMeta{2,Int64,Point{2,Int64},(:city, :rainfall),Tuple{String,Float64}} with indices SOneTo(2):
35-
3
36-
1
37-
38-
# metadata is stored in a NamedTuple and can be retrieved as such
39-
julia> meta(poi)
40-
(city = "Abuja", rainfall = 1221.2)
41-
42-
# specific metadata attributes can be directly retrieved
43-
julia> poi.rainfall
44-
1221.2
12+
This package aims to offer a standard set of geometry types that easily work
13+
with metadata, query frameworks on geometries and different memory layouts. The
14+
aim is to create a solid basis for graphics/plotting, finite element analysis,
15+
geo applications, and general geometry manipulations - while offering a Julian
16+
API that still allows performant C-interop.
4517

46-
# to remove the metadata and keep only the geometry, use metafree
47-
julia> metafree(poi)
48-
2-element Point{2,Int64} with indices SOneTo(2):
49-
3
50-
1
51-
52-
# for other geometries metatypes are predefined
53-
julia> multipoi = MultiPointMeta([p1], city="Abuja", rainfall=1221.2)
54-
1-element MultiPointMeta{Point{2,Int64},MultiPoint{2,Int64,Point{2,Int64},Array{Point{2,Int64},1}},(:city, :rainfall),Tuple{String,Float64}}:
55-
[3, 1]
56-
57-
# connect the points with lines
58-
julia> l1 = Line(p1, p2)
59-
Line([3, 1] => [1, 3])
60-
61-
julia> l2 = Line(p2, p3);
62-
63-
# connect the lines in a linestring
64-
julia> LineString([l1, l2])
65-
2-element LineString{2,Int64,Point{2,Int64},Array{GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}},1}}:
66-
Line([3, 1] => [1, 3])
67-
Line([1, 3] => [4, 4])
68-
69-
# linestrings can also be constructed directly from points
70-
julia> LineString([p1, p2, p3])
71-
2-element LineString{2,Int64,Point{2,Int64},Base.ReinterpretArray{GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}},1,Tuple{Point{2,Int64},Point{2,Int64}},TupleView{Tuple{Point{2,Int64},Point{2,Int64}}, 1}}}:
72-
Line([3, 1] => [1, 3])
73-
Line([1, 3] => [4, 4])
18+
This package is a replacement for the discontinued [GeometryTypes](https://github.com/JuliaGeometry/GeometryTypes.jl/).
7419

75-
# the same goes for polygons
76-
julia> Polygon(Point{2, Int}[(3, 1), (4, 4), (2, 4), (1, 2), (3, 1)])
77-
Polygon{2,Int64,Point{2,Int64},LineString{2,Int64,Point{2,Int64},Base.ReinterpretArray{GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}},1,Tuple{Point{2,Int64},Point{2,Int64}},TupleView{Tuple{Point{2,Int64},Point{2,Int64}}, 1}}},Array{LineString{2,Int64,Point{2,Int64},Base.ReinterpretArray{GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}},1,Tuple{Point{2,Int64},Point{2,Int64}},TupleView{Tuple{Point{2,Int64},Point{2,Int64}}, 1}}},1}}(GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}}[Line([3, 1] => [4, 4]), Line([4, 4] => [2, 4]), Line([2, 4] => [1, 2]), Line([1, 2] => [3, 1])], LineString{2,Int64,Point{2,Int64},Base.ReinterpretArray{GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}},1,Tuple{Point{2,Int64},Point{2,Int64}},TupleView{Tuple{Point{2,Int64},Point{2,Int64}}, 1}}}[])
20+
**Documentation:** http://juliageometry.github.io/GeometryBasics.jl/stable/
7821

79-
# create a rectangle placed at the origin with unit widths
80-
julia> rect = Rect(Vec(0.0, 0.0), Vec(1.0, 1.0))
81-
GeometryBasics.HyperRectangle{2,Float64}([0.0, 0.0], [1.0, 1.0])
22+
## Contributing
8223

83-
# decompose the rectangle into two triangular faces
84-
julia> rect_faces = decompose(TriangleFace{Int}, rect)
85-
2-element Array{NgonFace{3,Int64},1}:
86-
TriangleFace(1, 2, 4)
87-
TriangleFace(1, 4, 3)
24+
Make sure your changes don't break the documentation.
8825

89-
# decompose the rectangle into four vertices
90-
julia> rect_vertices = decompose(Point{2, Float64}, rect)
91-
4-element Array{Point{2,Float64},1}:
92-
[0.0, 0.0]
93-
[1.0, 0.0]
94-
[0.0, 1.0]
95-
[1.0, 1.0]
26+
To build the documentation locally, you first need to instantiate the `docs/` project:
9627

97-
# combine the vertices and faces into a triangle mesh
98-
julia> mesh = Mesh(rect_vertices, rect_faces)
99-
Mesh{2, Float64, Triangle}:
100-
Triangle([0.0, 0.0], [1.0, 0.0], [1.0, 1.0])
101-
Triangle([0.0, 0.0], [1.0, 1.0], [0.0, 1.0])
10228
```
29+
julia --project=docs/
30+
pkg> instantiate
31+
pkg> dev .
32+
```
33+
34+
Then use `julia --project=docs/ docs/make.jl` to build the documentation. This
35+
will also run the doctests defined in Markdown files. The doctests should be
36+
written for the Julia version configured in [ci.yml](.github/workflows/ci.yml)
37+
(`:docs` section).

docs/make.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ using GeometryBasics
66

77
DocMeta.setdocmeta!(GeometryBasics, :DocTestSetup, :(using GeometryBasics); recursive=true)
88

9-
# Copy the README to serve as the homepage
10-
cp(joinpath(@__DIR__, "..", "README.md"), joinpath(@__DIR__, "src", "index.md"))
11-
12-
makedocs(format=Documenter.HTML(), sitename="GeometryBasics.jl",
13-
pages=["index.md", "primitives.md", "rectangles.md", "polygons.md", "meshes.md",
14-
"decomposition.md", "distancefields.md", "metadata.md", "api.md"],
9+
makedocs(format=Documenter.HTML(prettyurls=get(ENV, "CI", "false") == "true"),
10+
sitename="GeometryBasics.jl",
11+
pages=[
12+
"index.md",
13+
"primitives.md",
14+
"rectangles.md",
15+
"polygons.md",
16+
"meshes.md",
17+
"decomposition.md",
18+
"metadata.md",
19+
"api.md"
20+
],
1521
modules=[GeometryBasics])
1622

1723
deploydocs(repo="github.com/JuliaGeometry/GeometryBasics.jl.git", push_preview=true)

docs/src/decomposition.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Decomposition
22

33

4-
## GeometryBasic Mesh interface
4+
## GeometryBasics Mesh interface
55

6-
GeometryBasic defines an interface, to decompose abstract geometries into
6+
GeometryBasics defines an interface to decompose abstract geometries into
77
points and triangle meshes.
88
This can be done for any arbitrary primitive, by overloading the following interface:
99

@@ -39,7 +39,7 @@ m = GeometryBasics.mesh(Tesselation(rect, (50, 50)))
3939
length(coordinates(m)) == 50^2
4040
```
4141

42-
As you can see, `coordinates` and `faces` is also defined on a mesh
42+
As you can see, `coordinates` and `faces` are also defined on a mesh
4343
```julia
4444
coordinates(m)
4545
faces(m)

docs/src/distancefields.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/src/index.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# GeometryBasics.jl
2+
3+
Basic geometry types.
4+
5+
This package aims to offer a standard set of geometry types that easily work
6+
with metadata, query frameworks on geometries and different memory layouts. The
7+
aim is to create a solid basis for graphics/plotting, finite element analysis,
8+
geo applications, and general geometry manipulations - while offering a Julian
9+
API that still allows performant C-interop.
10+
11+
This package is a replacement for the discontinued [GeometryTypes](https://github.com/JuliaGeometry/GeometryTypes.jl/).
12+
13+
## Quick start
14+
15+
Create some points:
16+
17+
```@repl quickstart
18+
using GeometryBasics
19+
20+
p1 = Point(3, 1)
21+
p2 = Point(1, 3);
22+
p3 = Point(4, 4);
23+
```
24+
25+
Geometries can carry metadata:
26+
27+
```@repl quickstart
28+
poi = meta(p1, city="Abuja", rainfall=1221.2)
29+
```
30+
31+
Metadata is stored in a NamedTuple and can be retrieved as such:
32+
33+
```@repl quickstart
34+
meta(poi)
35+
```
36+
37+
Specific metadata attributes can be directly retrieved:
38+
39+
```@repl quickstart
40+
poi.rainfall
41+
```
42+
43+
To remove the metadata and keep only the geometry, use `metafree`:
44+
45+
```@repl quickstart
46+
metafree(poi)
47+
```
48+
49+
Geometries have predefined metatypes:
50+
51+
```@repl quickstart
52+
multipoi = MultiPointMeta([p1], city="Abuja", rainfall=1221.2)
53+
```
54+
55+
Connect the points with lines:
56+
57+
```@repl quickstart
58+
l1 = Line(p1, p2)
59+
l2 = Line(p2, p3);
60+
```
61+
62+
Connect the lines in a linestring:
63+
64+
```@repl quickstart
65+
LineString([l1, l2])
66+
```
67+
68+
Linestrings can also be constructed directly from points:
69+
70+
```@repl quickstart
71+
LineString([p1, p2, p3])
72+
```
73+
74+
The same goes for polygons:
75+
76+
```@repl quickstart
77+
Polygon(Point{2, Int}[(3, 1), (4, 4), (2, 4), (1, 2), (3, 1)])
78+
```
79+
80+
Create a rectangle placed at the origin with unit width and height:
81+
82+
```@repl quickstart
83+
rect = Rect(Vec(0.0, 0.0), Vec(1.0, 1.0))
84+
```
85+
86+
Decompose the rectangle into two triangular faces:
87+
88+
```@repl quickstart
89+
rect_faces = decompose(TriangleFace{Int}, rect)
90+
```
91+
92+
Decompose the rectangle into four vertices:
93+
94+
```@repl quickstart
95+
rect_vertices = decompose(Point{2, Float64}, rect)
96+
```
97+
98+
Combine the vertices and faces into a triangle mesh:
99+
100+
```@repl quickstart
101+
mesh = Mesh(rect_vertices, rect_faces)
102+
```
103+
104+
Use `GeometryBasics.mesh` to get a mesh directly from a geometry:
105+
106+
```@repl quickstart
107+
mesh = GeometryBasics.mesh(rect)
108+
```

docs/src/meshes.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
## Types
44

5-
```@docs
6-
AbstractMesh
7-
Mesh
8-
```
5+
* [`AbstractMesh`](@ref)
6+
* [`Mesh`](@ref)
97

108
## How to create a mesh
119

0 commit comments

Comments
 (0)