From fafa06794b12ea002b07472e27e534d984c7797d Mon Sep 17 00:00:00 2001 From: Bagaev Dmitry Date: Wed, 19 Feb 2025 14:18:24 +0100 Subject: [PATCH] add sitemap generation --- docs/Project.toml | 1 + docs/make.jl | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/docs/Project.toml b/docs/Project.toml index 111718ea0..d072ee32f 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -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" diff --git a/docs/make.jl b/docs/make.jl index 326f882a6..9a86b07a7 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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 @@ -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 = """ + + """ + + # 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 + new_content = replace(content, r"" => meta_tags * "") + + # 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 = """ +""" + + # 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 *= """ + + $(full_url) + $(current_date) + weekly + 0.8 + """ + end + end + end + + sitemap_content *= "\n" + + # 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)