Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try out Runic formatting #138

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions docs/liveserver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ Pkg.activate(@__DIR__)
Pkg.instantiate()
import LiveServer
withenv("LIVESERVER_ACTIVE" => "true") do
LiveServer.servedocs(;
launch_browser=true,
foldername=joinpath(repo_root, "docs"),
include_dirs=[joinpath(repo_root, "src")],
skip_dirs=[joinpath(repo_root, "docs/src/tutorials"),
LiveServer.servedocs(
;
Comment on lines +7 to +8

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look a bit stupid -- The ; should be directly after the opening ( I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be better

Copy link

@fredrikekre fredrikekre Jul 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed on Runic master

launch_browser = true,
foldername = joinpath(repo_root, "docs"),
include_dirs = [joinpath(repo_root, "src")],
skip_dirs = [
joinpath(repo_root, "docs/src/tutorials"),
joinpath(repo_root, "docs/src/applications"),
joinpath(repo_root, "docs/src/figures"),
],
Expand Down
102 changes: 60 additions & 42 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ using Literate
using Test
using Dates

DocMeta.setdocmeta!(DelaunayTriangulation, :DocTestSetup, :(using DelaunayTriangulation, Test);
recursive=true)

DocMeta.setdocmeta!(
DelaunayTriangulation, :DocTestSetup, :(using DelaunayTriangulation, Test);
recursive = true,
)


const IS_LIVESERVER = false && get(ENV, "LIVESERVER_ACTIVE", "false") == "true"
if IS_LIVESERVER
Expand All @@ -20,6 +24,7 @@ function safe_include(filename)
end
const session_tmp = mktempdir()


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you manually insert all of these extra newlines? I am guessing this could be another Windows-related line ending bug if not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't do anything after running the formatter. It looks like the bug since it looked fine originally https://github.com/JuliaGeometry/DelaunayTriangulation.jl/blob/main/docs/make.jl

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed in JuliaSyntax 0.4.9

# When running docs locally, the EditURL is incorrect. For example, we might get
# ```@meta
# EditURL = "<unknown>/docs/src/literate_tutorials/constrained.jl"
Expand All @@ -36,12 +41,13 @@ function update_edit_url(content, file, folder)
return content
end


# We can add the code to the end of each file in its uncommented form programatically.
function add_just_the_code_section(dir, file)
file_name, file_ext = splitext(file)
file_path = joinpath(dir, file)
new_file_path = joinpath(session_tmp, file_name * "_just_the_code" * file_ext)
cp(file_path, new_file_path, force=true)
cp(file_path, new_file_path, force = true)
folder = splitpath(dir)[end] # literate_tutorials or literate_applications
open(new_file_path, "a") do io
write(io, "\n")
Expand All @@ -56,6 +62,7 @@ function add_just_the_code_section(dir, file)
return new_file_path
end


# Now process all the literate files
ct() = Dates.format(now(), "HH:MM:SS")
for folder in ("tutorials", "applications")
Expand All @@ -74,7 +81,7 @@ for folder in ("tutorials", "applications")
# end
#end
new_file_path = add_just_the_code_section(dir, file)
script = Literate.script(file_path, session_tmp, name=splitext(file)[1] * "_just_the_code_cleaned")
script = Literate.script(file_path, session_tmp, name = splitext(file)[1] * "_just_the_code_cleaned")
code = strip(read(script, String))
@info "[$(ct())] Processing $file: Converting markdown script"
line_ending_symbol = occursin(code, "\r\n") ? "\r\n" : "\n"
Expand All @@ -86,16 +93,17 @@ for folder in ("tutorials", "applications")
Literate.markdown(
new_file_path,
outputdir;
documenter=true,
postprocess=editurl_update ∘ post_strip,
credit=true,
name=splitext(file)[1],
execute=!IS_LIVESERVER,
flavor=Literate.DocumenterFlavor(),
documenter = true,
postprocess = editurl_update ∘ post_strip,
credit = true,
name = splitext(file)[1],
execute = !IS_LIVESERVER,
flavor = Literate.DocumenterFlavor(),
)
end
end


# All the pages to be included
const _PAGES = [
"Introduction" => "index.md",
Expand Down Expand Up @@ -127,15 +135,15 @@ const _PAGES = [
"Voronoi Tessellations" => "tutorials/voronoi.md",
"Clipped Voronoi Tessellations" => [
"Clipping to the Convex Hull" => "tutorials/clipped.md",
"Clipping to a Rectangle" => "tutorials/clipped_rectangle.md"
"Clipping to a Rectangle" => "tutorials/clipped_rectangle.md",
],
"Centroidal Voronoi Tessellations" => "tutorials/centroidal.md",
"Point Location" => "tutorials/point_location.md",
"Nearest Neighbour Queries" => "tutorials/nearest.md",
"Convex Hulls" => "tutorials/convex_hull.md",
"Pole of Inaccessibility" => "tutorials/pole_of_inaccessibility.md",
"Point-in-Polygon Testing" => "tutorials/point_in_polygon.md",
"Using Custom Structs for Primitives and Boundaries" => "tutorials/custom_primitive.md"
"Using Custom Structs for Primitives and Boundaries" => "tutorials/custom_primitive.md",
],
"Manual" => [
"Overview" => "manual/overview.md",
Expand Down Expand Up @@ -168,7 +176,7 @@ const _PAGES = [
"Data Structures" => "extended/data_structures.md",
"Algorithm Internals" => "extended/algorithms.md",
"Utility Functions" => "extended/utils.md",
],
],
"Mathematical Details" => [
"Overview" => "math/overview.md",
"Delaunay Triangulations" => "math/delaunay.md",
Expand All @@ -190,6 +198,7 @@ const _PAGES = [
"Terminology" => "terminology.md",
]


# Make sure we haven't forgotten any files
set = Set{String}()
for page in _PAGES
Expand Down Expand Up @@ -219,36 +228,45 @@ for (root, dir, files) in walkdir(doc_dir)
end
!isempty(missing_set) && error("Missing files: $missing_set")


# Make and deploy
makedocs(;
modules=[DelaunayTriangulation],
authors="Daniel VandenHeuvel <[email protected]>",
sitename="DelaunayTriangulation.jl",
format=Documenter.HTML(;
prettyurls=IS_CI,
canonical="https://JuliaGeometry.github.io/DelaunayTriangulation.jl",
edit_link="main",
size_threshold=8000 * 2^10,
size_threshold_warn=1000 * 2^10,
size_threshold_ignore=["api/triangulation.md", "extended/data_structures.md"],
collapselevel=1,
assets=String[],
mathengine=MathJax3(Dict(
:loader => Dict("load" => ["[tex]/physics"]),
:tex => Dict(
"inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
"tags" => "ams",
"packages" => ["base", "ams", "autoload", "physics"],
makedocs(
;
modules = [DelaunayTriangulation],
authors = "Daniel VandenHeuvel <[email protected]>",
sitename = "DelaunayTriangulation.jl",
format = Documenter.HTML(
;
prettyurls = IS_CI,
canonical = "https://JuliaGeometry.github.io/DelaunayTriangulation.jl",
edit_link = "main",
size_threshold = 8000 * 2^10,
size_threshold_warn = 1000 * 2^10,
size_threshold_ignore = ["api/triangulation.md", "extended/data_structures.md"],
collapselevel = 1,
assets = String[],
mathengine = MathJax3(
Dict(
:loader => Dict("load" => ["[tex]/physics"]),
:tex => Dict(
"inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
"tags" => "ams",
"packages" => ["base", "ams", "autoload", "physics"],
),
),
))),
linkcheck=false,
warnonly=true,
draft=IS_LIVESERVER,
pages=_PAGES,
pagesonly=true,
),
),
linkcheck = false,
warnonly = true,
draft = IS_LIVESERVER,
pages = _PAGES,
pagesonly = true,
)

deploydocs(;
repo="github.com/JuliaGeometry/DelaunayTriangulation.jl",
devbranch="main",
push_preview=true)

deploydocs(
;
repo = "github.com/JuliaGeometry/DelaunayTriangulation.jl",
devbranch = "main",
push_preview = true,
)
13 changes: 7 additions & 6 deletions src/algorithms/convex_hull.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ Computes the convex hull of `points`. The monotone chain algorithm is used.
# Output
- `ch`: The [`ConvexHull`](@ref).
"""
function convex_hull(points; IntegerType::Type{I}=Int) where {I}
function convex_hull(points; IntegerType::Type{I} = Int) where {I}
ch = ConvexHull(points, I[])
sizehint!(ch, num_points(points))
return convex_hull!(ch)
end


"""
convex_hull!(ch::ConvexHull{P,I}) where {P,I}

Using the points in `ch`, computes the convex hull in-place.

See also [`convex_hull`](@ref).
"""
function convex_hull!(ch::ConvexHull{P,I}) where {P,I}
function convex_hull!(ch::ConvexHull{P, I}) where {P, I}
indices = get_vertices(ch)
points = get_points(ch)
empty!(indices)
Expand All @@ -34,10 +35,10 @@ function convex_hull!(ch::ConvexHull{P,I}) where {P,I}
push!(indices, insertion_order[begin])
return ch
elseif n == 2
push!(indices, insertion_order[begin], insertion_order[begin+1], insertion_order[begin])
push!(indices, insertion_order[begin], insertion_order[begin + 1], insertion_order[begin])
return ch
elseif n == 3
i, j, k = construct_positively_oriented_triangle(NTuple{3,I}, insertion_order[begin], insertion_order[begin+1], insertion_order[begin+2], points)
i, j, k = construct_positively_oriented_triangle(NTuple{3, I}, insertion_order[begin], insertion_order[begin + 1], insertion_order[begin + 2], points)
push!(indices, i, j, k, i)
return ch
end
Expand All @@ -46,13 +47,13 @@ function convex_hull!(ch::ConvexHull{P,I}) where {P,I}
sizehint!(lower, max(4, floor(I, cbrt(n))))
sizehint!(upper, max(4, floor(I, cbrt(n))))
for i in eachindex(insertion_order)
while length(upper) ≥ 2 && is_left(point_position_relative_to_line(get_point(points, upper[end-1]), get_point(points, upper[end]), get_point(points, insertion_order[i])))
while length(upper) ≥ 2 && is_left(point_position_relative_to_line(get_point(points, upper[end - 1]), get_point(points, upper[end]), get_point(points, insertion_order[i])))
pop!(upper)
end
push!(upper, insertion_order[i])
end
for i in lastindex(insertion_order):-1:firstindex(insertion_order)
while length(lower) ≥ 2 && is_left(point_position_relative_to_line(get_point(points, lower[end-1]), get_point(points, lower[end]), get_point(points, insertion_order[i])))
while length(lower) ≥ 2 && is_left(point_position_relative_to_line(get_point(points, lower[end - 1]), get_point(points, lower[end]), get_point(points, insertion_order[i])))
pop!(lower)
end
push!(lower, insertion_order[i])
Expand Down
Loading
Loading