From fdc56a0921a127e0f3d3b459ed53e70c416572c6 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Fri, 27 Sep 2019 23:58:09 -0400 Subject: [PATCH] Rewrite Dokka-generated markdown to include titles. I tried rendering in jekyll mode but that doesn't look as nice with Mkdocs. --- deploy_website.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/deploy_website.sh b/deploy_website.sh index 202321d658d9..3f5d077f2cf6 100755 --- a/deploy_website.sh +++ b/deploy_website.sh @@ -30,6 +30,26 @@ cd $DIR :okhttp-urlconnection:dokka \ :okhttp:dokka +# Dokka filenames like `-http-url/index.md` don't work well with MkDocs tags. +# Assign metadata to the file's first Markdown heading. +# https://www.mkdocs.org/user-guide/writing-your-docs/#meta-data +title_markdown_file() { + TITLE_PATTERN="s/^[#]+ *(.*)/title: \1 - OkHttp/" + echo "---" > "$1.fixed" + cat $1 | sed -E "$TITLE_PATTERN" | grep "title: " | head -n 1 >> "$1.fixed" + echo "---" >> "$1.fixed" + echo >> "$1.fixed" + cat $1 >> "$1.fixed" + mv "$1.fixed" "$1" +} + +set +x +for MARKDOWN_FILE in $(find docs/4.x/ -name '*.md'); do + echo $MARKDOWN_FILE + title_markdown_file $MARKDOWN_FILE +done +set -x + # Copy in special files that GitHub wants in the project root. cat README.md | grep -v 'project website' > docs/index.md cp CHANGELOG.md docs/changelog.md