|
1 | 1 | using RxInfer |
2 | 2 | using Documenter |
3 | 3 | using DocumenterMermaid |
| 4 | +using Dates |
4 | 5 |
|
5 | 6 | ## https://discourse.julialang.org/t/generation-of-documentation-fails-qt-qpa-xcb-could-not-connect-to-display/60988 |
6 | 7 | ## https://gr-framework.org/workstations.html#no-output |
@@ -64,4 +65,85 @@ makedocs(; |
64 | 65 | ] |
65 | 66 | ) |
66 | 67 |
|
| 68 | +# Function to inject keywords meta tag into HTML files |
| 69 | +function inject_keywords_meta() |
| 70 | + # Define keywords for the documentation |
| 71 | + keywords = "Julia, Bayesian inference, factor graph, message passing, probabilistic programming, reactive programming, RxInfer" |
| 72 | + base_url = "https://reactivebayes.github.io/RxInfer.jl/stable" |
| 73 | + |
| 74 | + # Meta tags to inject |
| 75 | + meta_tags = """ |
| 76 | + <meta name="keywords" content="$(keywords)"> |
| 77 | + <link rel="sitemap" type="application/xml" title="Sitemap" href="$(base_url)/sitemap.xml">""" |
| 78 | + |
| 79 | + # List of files to exclude |
| 80 | + exclude_files = ["googlef2b9004e34bc8cf4.html"] |
| 81 | + |
| 82 | + # Process all HTML files in the build directory |
| 83 | + for (root, _, files) in walkdir("docs/build") |
| 84 | + for file in files |
| 85 | + if endswith(file, ".html") && !(file in exclude_files) |
| 86 | + filepath = joinpath(root, file) |
| 87 | + content = read(filepath, String) |
| 88 | + |
| 89 | + # Insert meta tags before </head> |
| 90 | + new_content = replace(content, r"</head>" => meta_tags * "</head>") |
| 91 | + |
| 92 | + # Write the modified content back |
| 93 | + write(filepath, new_content) |
| 94 | + end |
| 95 | + end |
| 96 | + end |
| 97 | +end |
| 98 | + |
| 99 | +# Function to generate sitemap.xml |
| 100 | +function generate_sitemap() |
| 101 | + base_url = "https://reactivebayes.github.io/RxInfer.jl" |
| 102 | + sitemap_content = """<?xml version="1.0" encoding="UTF-8"?> |
| 103 | +<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">""" |
| 104 | + |
| 105 | + # List of files to exclude |
| 106 | + exclude_files = ["googlef2b9004e34bc8cf4.html", "404.html", "search_index.js"] |
| 107 | + |
| 108 | + # Current date in W3C format |
| 109 | + current_date = Dates.format(Dates.now(), "yyyy-mm-dd") |
| 110 | + |
| 111 | + # Process all HTML files in the build directory |
| 112 | + for (root, _, files) in walkdir("docs/build") |
| 113 | + for file in files |
| 114 | + if endswith(file, ".html") && !(file in exclude_files) |
| 115 | + # Get relative path from build directory |
| 116 | + rel_path = relpath(joinpath(root, file), "docs/build") |
| 117 | + # Convert Windows path separators if present |
| 118 | + url_path = replace(rel_path, '\\' => '/') |
| 119 | + # Remove index.html from the end if present |
| 120 | + url_path = replace(url_path, r"/index.html$" => "/") |
| 121 | + # Remove .html from the end of all other files |
| 122 | + url_path = replace(url_path, r"\.html$" => "") |
| 123 | + |
| 124 | + # Construct full URL |
| 125 | + full_url = string(base_url, "/", url_path) |
| 126 | + |
| 127 | + # Add URL entry to sitemap |
| 128 | + sitemap_content *= """ |
| 129 | + <url> |
| 130 | + <loc>$(full_url)</loc> |
| 131 | + <lastmod>$(current_date)</lastmod> |
| 132 | + <changefreq>weekly</changefreq> |
| 133 | + <priority>0.8</priority> |
| 134 | + </url>""" |
| 135 | + end |
| 136 | + end |
| 137 | + end |
| 138 | + |
| 139 | + sitemap_content *= "\n</urlset>" |
| 140 | + |
| 141 | + # Write sitemap to the build directory |
| 142 | + write("docs/build/sitemap.xml", sitemap_content) |
| 143 | +end |
| 144 | + |
| 145 | +# Call the functions after makedocs |
| 146 | +inject_keywords_meta() |
| 147 | +generate_sitemap() |
| 148 | + |
67 | 149 | deploydocs(; repo = "github.com/ReactiveBayes/RxInfer.jl", devbranch = "main", forcepush = true) |
0 commit comments