Skip to content

Commit

Permalink
Manually fix referencing in LossFunctions.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Mar 18, 2023
1 parent 2fbcdcc commit a22e5b7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
@@ -1,2 +1,3 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a"
28 changes: 28 additions & 0 deletions docs/make.jl
Expand Up @@ -54,4 +54,32 @@ makedocs(;
),
)

# Next, we fix links in the docs/build/losses/index.html file:
using Gumbo

html_type(::HTMLElement{S}) where {S} = S

function apply_to_a_href!(f!, element::HTMLElement)
if html_type(element) == :a && haskey(element.attributes, "href") && element.attributes["href"] == "@ref"
f!(element)
else
for child in element.children
typeof(child) <: HTMLElement && apply_to_a_href!(f!, child)
end
end
end

html_content = read("docs/build/losses/index.html", String)
html = parsehtml(html_content)

apply_to_a_href!(html.root) do element
# Replace the "href" to be equal to the contents of the tag, prefixed with #:
element.attributes["href"] = "#LossFunctions." * element.children[1].text
end

# Then, we write the new html to the file:
open("docs/build/losses/index.html", "w") do io
write(io, string(html))
end

deploydocs(; repo="github.com/MilesCranmer/SymbolicRegression.jl.git")

0 comments on commit a22e5b7

Please sign in to comment.