Skip to content

Commit

Permalink
fixes URL rewriter, adds page surpressor, adds gif support
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle J. Davis <[email protected]>
  • Loading branch information
stockholmux committed May 31, 2024
1 parent 6a95e30 commit 37372b1
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/init-topics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ done

echo "Topic stub files created."

for fname in $(find $1 -maxdepth 1 -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg")
for fname in $(find $1 -maxdepth 1 -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.gif")
do
base=${fname##*/}
cp ${fname} ./content/docs/topics/${base}
Expand Down
40 changes: 40 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,50 @@ build_search_index = true
[markdown]
highlight_code = true

# This is included to override any differences slugs and documentation source filenames
[extra.slug_source_exceptions]
"valkey-conf" = "valkey.conf"

[extra]
command_description_path = "../build-command-docs/"
command_json_path = "../build-command-json/"
doc_topic_path = "../build-topics/"

review_list = [
"/docs/topics/license/",
"/docs/topics/admin/",
"/docs/topics/distlock/",
"/docs/topics/eval-intro/",
"/docs/topics/faq/",
"/docs/topics/functions-intro/",
"/docs/topics/hashes/",
"/docs/topics/internals-eventlib/",
"/docs/topics/internals-vm/",
"/docs/topics/internals/",
"/docs/topics/latency/",
"/docs/topics/lua-api/",
"/docs/topics/modules-blocking-ops/",
"/docs/topics/modules-intro/",
"/docs/topics/pipelining/",
"/docs/topics/programmability/",
"/docs/topics/protocol/",
"/docs/topics/pubsub/",
"/docs/topics/rdd/",
"/docs/topics/replication/",
"/docs/topics/security/",
"/docs/topics/sentinel-clients/",
"/docs/topics/sentinel/",
"/docs/topics/transactions/",
"/docs/topics/cluster-spec/",
"/docs/topics/history/"
]

publish_hold = [
"/docs/topics/protocol/",
"/docs/topics/license/",
"/docs/topics/internals-eventlib/",
"/docs/topics/internals-vm/",
"/docs/topics/internals/",
"/docs/topics/protocol/",
"/docs/topics/rdd/"
]
6 changes: 5 additions & 1 deletion templates/docs-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ <h1 class="page-title">{{ frontmatter_title }}</h1>
<hr />
{% endif %}
{%- set content_with_fixed_links = docs::fix_links(content= page_contents) -%}
{{ content_with_fixed_links | markdown | safe }}
{% if config.extra.publish_hold is containing(page.path) %}
<p><code>{{ page.path }}</code> may be available after revisions.</p>
{% else %}
{{ content_with_fixed_links | markdown | safe }}
{% endif %}
{% endblock main_content %}
16 changes: 12 additions & 4 deletions templates/macros/docs.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{%- macro load(slug) -%}
{%- set topic_path = config.extra.doc_topic_path -%}
{%- if slug in config.extra.slug_source_exceptions -%}
{%- set slug = config.extra.slug_source_exceptions[slug] -%}
{%- endif -%}
{%- set markdown_content = load_data(path= topic_path ~ "/" ~ slug ~ ".md", required= false) -%}
{%- if markdown_content -%}{{ markdown_content }}{% endif %}
{% endmacro load_doc %}
Expand All @@ -21,11 +24,16 @@

{%- macro fix_links(content) -%}
{{ content
| regex_replace(pattern=`\]\((?P<fname>.*?)\w.png\)`, rep=`](/docs/topics/$fname.png)`)
| regex_replace(pattern=`\]\(\.\./commands/(?P<fname>\w.*?)(.md)?\)`, rep=`](/commands/$fname)`)
| regex_replace(pattern=`\]\(#(?P<hash>.*?\))`, rep=`](--$hash`)
| regex_replace(pattern=`\]\((?P<url>httpsd?:\/\/.*?\))`, rep=`](-$url`)
| regex_replace(pattern=`\]\(\.\./commands/(?P<fname>\w.*?)(.md)?#(?P<hash>.*?)\)`, rep=`](/commands/$fname#$hash)`)
| regex_replace(pattern=`\]\(\.\./commands/(?P<fname>\w.*?)(.md)?\)`, rep=`](/commands/$fname)`)
| regex_replace(pattern=`\]\(\.\./commands/#(?P<hash>\w.*?)\)`, rep=`](/commands/#$hash)`)
| regex_replace(pattern=`\]\((?P<fname>\w.*?)(.md)?#(?P<hash>.*?)\)`, rep=`](/docs/topics/$fname#$hash)`)
| regex_replace(pattern=`\]\((?P<fname>.*?).png\)`, rep=`](/docs/topics/$fname.png)`)
| regex_replace(pattern=`\]\((?P<fname>.*?).gif\)`, rep=`](/docs/topics/$fname.gif)`)
| regex_replace(pattern=`\]\((?P<fname>\w.*?)(.md)?\)`, rep=`](/docs/topics/$fname)`)
| regex_replace(pattern=`\]\(\/docs\/topics/http\:`, rep=`](http:`)
}}
| regex_replace(pattern=`\]\(\-(?P<url>https?:\/\/.*?\))`, rep=`]($url`)
| regex_replace(pattern=`\]\(\--(?P<hash>.*?\))`, rep=`](#$hash`)
}}
{%- endmacro fix_links -%}

0 comments on commit 37372b1

Please sign in to comment.