Skip to content

Commit

Permalink
add sitemap generation
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdmitri committed Feb 19, 2025
1 parent 7331c13 commit fafa067
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
BayesBase = "b4ee3484-f114-42fe-b91c-797d54a0c67e"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterMermaid = "a078cd44-4d9c-4618-b545-3ab9d77f9177"
Expand Down
82 changes: 82 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using RxInfer
using Documenter
using DocumenterMermaid
using Dates

## https://discourse.julialang.org/t/generation-of-documentation-fails-qt-qpa-xcb-could-not-connect-to-display/60988
## https://gr-framework.org/workstations.html#no-output
Expand Down Expand Up @@ -64,4 +65,85 @@ makedocs(;
]
)

# Function to inject keywords meta tag into HTML files
function inject_keywords_meta()
# Define keywords for the documentation
keywords = "Julia, Bayesian inference, factor graph, message passing, probabilistic programming, reactive programming, RxInfer"
base_url = "https://reactivebayes.github.io/RxInfer.jl/stable"

# Meta tags to inject
meta_tags = """
<meta name="keywords" content="$(keywords)">
<link rel="sitemap" type="application/xml" title="Sitemap" href="$(base_url)/sitemap.xml">"""

# List of files to exclude
exclude_files = ["googlef2b9004e34bc8cf4.html"]

# Process all HTML files in the build directory
for (root, _, files) in walkdir("docs/build")
for file in files
if endswith(file, ".html") && !(file in exclude_files)
filepath = joinpath(root, file)
content = read(filepath, String)

# Insert meta tags before </head>
new_content = replace(content, r"</head>" => meta_tags * "</head>")

# Write the modified content back
write(filepath, new_content)
end
end
end
end

# Function to generate sitemap.xml
function generate_sitemap()
base_url = "https://reactivebayes.github.io/RxInfer.jl"
sitemap_content = """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">"""

# List of files to exclude
exclude_files = ["googlef2b9004e34bc8cf4.html", "404.html", "search_index.js"]

# Current date in W3C format
current_date = Dates.format(Dates.now(), "yyyy-mm-dd")

# Process all HTML files in the build directory
for (root, _, files) in walkdir("docs/build")
for file in files
if endswith(file, ".html") && !(file in exclude_files)
# Get relative path from build directory
rel_path = relpath(joinpath(root, file), "docs/build")
# Convert Windows path separators if present
url_path = replace(rel_path, '\\' => '/')
# Remove index.html from the end if present
url_path = replace(url_path, r"/index.html$" => "/")
# Remove .html from the end of all other files
url_path = replace(url_path, r"\.html$" => "")

# Construct full URL
full_url = string(base_url, "/", url_path)

# Add URL entry to sitemap
sitemap_content *= """
<url>
<loc>$(full_url)</loc>
<lastmod>$(current_date)</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>"""
end
end
end

sitemap_content *= "\n</urlset>"

# Write sitemap to the build directory
write("docs/build/sitemap.xml", sitemap_content)
end

# Call the functions after makedocs
inject_keywords_meta()
generate_sitemap()

deploydocs(; repo = "github.com/ReactiveBayes/RxInfer.jl", devbranch = "main", forcepush = true)

2 comments on commit fafa067

@bvdmitri
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/125420

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v4.0.1 -m "<description of version>" fafa06794b12ea002b07472e27e534d984c7797d
git push origin v4.0.1

Please sign in to comment.