Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# build workspace
/dotnet
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@

# The Book of the Runtime Build Repo

[![Build Docs](https://github.com/jurakovic/runtime/actions/workflows/build.yaml/badge.svg)](https://github.com/jurakovic/runtime/actions/workflows/build.yaml)

This repository is a fork of the [dotnet/runtime](https://github.com/dotnet/runtime), created solely to build the [_Book of the Runtime_](https://github.com/dotnet/runtime/tree/main/docs/design/coreclr/botr/README.md) using MkDocs and host it on GitHub Pages.

The site provides easy-to-navigate interface with dark and light themes and interactive search functionality.

It is available at <https://jurakovic.github.io/runtime/>.

> **Disclaimer:**
> This is an unofficial documentation site and is not affiliated with Microsoft.
> Microsoft and .NET are trademarks of Microsoft Corporation.

## Overview

This repo has two *main* branches:
Expand Down
166 changes: 93 additions & 73 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,75 +1,95 @@
#!/bin/bash

echo "Creating new 'dotnet' worktree with 'main' branch"
git worktree add dotnet main
cd dotnet
git pull

# clear any leftovers
rm -rf site

# temp config
cp ../mkdocs.yml .

# copy out-of-scope files
cp docs/design/coreclr/botr/../jit/ryujit-overview.md docs/design/coreclr/botr/ryujit-overview.md
cp docs/design/coreclr/botr/../jit/porting-ryujit.md docs/design/coreclr/botr/porting-ryujit.md

# fix profiling.md; e.g. List<int> => List&lt;int&gt;
sed -i -r 's/(\w+)(<)([a-zA-Z,]+)(>)/\1\&lt;\3\&gt;/g' docs/design/coreclr/botr/profiling.md

# temp fix to images path in jit file
sed -i -r 's;]\(images;]\(https://raw.githubusercontent.com/dotnet/runtime/refs/heads/main/docs/design/coreclr/jit/images;g' docs/design/coreclr/botr/ryujit-overview.md

mapfile -t files < <(find docs/design/coreclr/botr -type f -iwholename "*.md")
for file in "${files[@]}"; do
# hide toc on all pages (no other proposed solutions work)
sed -i '1s/^/---\nhide:\n - toc\n---\n/' "$file"
# update links to jit files, because they are copied to botr dir (cp commands above)
sed -i -r 's;(\.\.\/jit\/)(.*\.md);\2;g' "$file"
# change relative links for out-of-scope files to github
sed -i -r 's;(\(|]: )\.\./\.\./\.\./\.\./;\1https://github.com/dotnet/runtime/blob/main/;g' "$file"
sed -i -r 's;(\(|]: )\.\./\.\./\.\./;\1https://github.com/dotnet/runtime/blob/main/docs/;g' "$file"
sed -i -r 's;(\(|]: )\.\./\.\./;\1https://github.com/dotnet/runtime/blob/main/docs/design/;g' "$file"
sed -i -r 's;(\(|]: )\.\./;\1https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/;g' "$file"
done

echo "Staring mkdocs build"
docker run --rm -v ${PWD}:/docs ghcr.io/jurakovic/mkdocs-botr:latest build </dev/null
#for debugging:
#docker run --rm -it -v ${PWD}:/docs --entrypoint /bin/sh ghcr.io/jurakovic/mkdocs-botr:latest

# back to repo root
cd ..

# clear old build
rm -rf docs

# move to docs dir
mv dotnet/site docs
rm -rf dotnet

# change dotnet repo to fork; fix api url
find docs -type f -iwholename "*.html" -exec sed -i -r 's|(href="https://github.com/)(dotnet)(/runtime" title="Go to repository")|\1jurakovic\3|' {} +
find docs/assets/javascripts -type f -iwholename "*.min.js" -exec sed -i -r 's|(https://api.github.com/repos/)(\$\{e\}/\$\{t\})|\1dotnet/runtime|' {} +

# change view url from raw to github
find docs -type f -iwholename "*.html" -exec sed -i -r 's|(href="https://github\.com/dotnet/runtime/)(raw)(.*" title="View source of this page")|\1blob\3 target="_blank"|' {} +
sed -i -r 's|(href="https://github\.com/dotnet/runtime/blob/main/docs/design/coreclr/)(botr)(.*" title="View source of this page")|\1jit\3"|' docs/ryujit-overview/*.html docs/porting-ryujit/*.html

# fix index urls
sed -i -r 's|(">All Book of the Runtime \(BOTR\) chapters on GitHub)|" target="_blank\1|' docs/index.html

# add footer url
text='in <a href="https://github.com/jurakovic/runtime" target="_blank">jurakovic/runtime</a>'
mapfile -t files < <(find docs -type f -iwholename "*.html")
for file in "${files[@]}"; do
total_lines=$(wc -l < "$file")
insert_line=$((total_lines - 48))
sed -i "${insert_line}i$text" "$file"
done

echo "Removing 'dotnet' worktree"
git worktree remove dotnet --force

echo "Done"
docs_dir='docs/design/coreclr/botr'

function add_worktree {
echo "Adding new 'dotnet' worktree with 'main' branch"
git worktree add dotnet main
cd dotnet
git pull
}

function copy_mkdocs_config {
cp ../mkdocs.yml .
cp ../custom.css $docs_dir/custom.css
mkdir -p overrides/partials
cp ../favicon.svg $docs_dir/favicon.svg
cp ../copyright.html overrides/partials/copyright.html
}

function pre_build {
# copy out-of-scope files
cp $docs_dir/../jit/ryujit-overview.md $docs_dir/ryujit-overview.md
cp $docs_dir/../jit/porting-ryujit.md $docs_dir/porting-ryujit.md

# fix profiling.md; e.g. List<int> => List&lt;int&gt;
sed -i -r 's/(\w+)(<)([a-zA-Z,]+)(>)/\1\&lt;\3\&gt;/g' $docs_dir/profiling.md

# temp fix to images path in jit file
sed -i -r 's;]\(images;]\(https://raw.githubusercontent.com/dotnet/runtime/refs/heads/main/docs/design/coreclr/jit/images;g' $docs_dir/ryujit-overview.md

mapfile -t files < <(find $docs_dir -type f -iwholename "*.md")
for file in "${files[@]}"; do
# hide toc on all pages (no other proposed solutions work)
sed -i '1s/^/---\nhide:\n - toc\n---\n/' "$file"
# update links to jit files, because they are copied to botr dir (cp commands above)
sed -i -r 's;(\.\.\/jit\/)(.*\.md);\2;g' "$file"
# change relative links for out-of-scope files to github
sed -i -r 's;(\(|]: )\.\./\.\./\.\./\.\./;\1https://github.com/dotnet/runtime/blob/main/;g' "$file"
sed -i -r 's;(\(|]: )\.\./\.\./\.\./;\1https://github.com/dotnet/runtime/blob/main/docs/;g' "$file"
sed -i -r 's;(\(|]: )\.\./\.\./;\1https://github.com/dotnet/runtime/blob/main/docs/design/;g' "$file"
sed -i -r 's;(\(|]: )\.\./;\1https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/;g' "$file"
done
}

function build {
echo "Staring mkdocs build"

# clear any leftovers
rm -rf site

docker run --rm -v ${PWD}:/docs ghcr.io/jurakovic/mkdocs-botr:latest build </dev/null
#for debugging:
#docker run --rm -it -v ${PWD}:/docs --entrypoint /bin/sh ghcr.io/jurakovic/mkdocs-botr:latest

# back to repo root
cd ..

# clear old build
rm -rf docs

# move to docs dir
mv dotnet/site docs
}

function post_build {
# change dotnet repo to fork; fix api url
find docs -type f -iwholename "*.html" -exec sed -i -r 's|(href="https://github.com/)(dotnet)(/runtime" title="Go to repository")|\1jurakovic\3|' {} +
find docs/assets/javascripts -type f -iwholename "*.min.js" -exec sed -i -r 's|(https://api.github.com/repos/)(\$\{e\}/\$\{t\})|\1dotnet/runtime|' {} +

# change view url from raw to github
find docs -type f -iwholename "*.html" -exec sed -i -r 's|(href="https://github\.com/dotnet/runtime/)(raw)(.*" title="View source of this page")|\1blob\3 target="_blank"|' {} +
sed -i -r 's|(href="https://github\.com/dotnet/runtime/blob/main/docs/design/coreclr/)(botr)(.*" title="View source of this page")|\1jit\3"|' docs/ryujit-overview/*.html docs/porting-ryujit/*.html

# fix index urls
sed -i -r 's|(">All Book of the Runtime \(BOTR\) chapters on GitHub)|" target="_blank\1|' docs/index.html
}

function remove_worktree {
echo "Removing 'dotnet' worktree"
rm -rf dotnet
git worktree remove dotnet --force
}

function main {
#cd dotnet
add_worktree
copy_mkdocs_config
pre_build
build
post_build
remove_worktree
echo "Done"
}

main
7 changes: 7 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
curr=$(curl -s "https://api.github.com/repos/dotnet/runtime/commits?path=docs/design/coreclr/botr&per_page=1" | jq -r '.[0].sha')
prev=$(cat commit.txt)

if [ -z "$curr" ] || [ "$curr" = "null" ]; then
echo "Failed to fetch latest commit"
exit 1
fi

if [ $curr = $prev ]
then
echo "There are no changes"
Expand All @@ -17,3 +22,5 @@ if [ -z "$yn" ] || [ "$yn" != "y" ]; then exit 1; fi;
./build.sh

echo "$curr" > commit.txt

git diff --name-only $prev $curr -- docs/design/coreclr/botr
17 changes: 17 additions & 0 deletions copyright.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="md-copyright">
{% if config.copyright %}
<div class="md-copyright__highlight">
{{ config.copyright }}
</div>
{% endif %}
{% if not config.extra.generator == false %}
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
in
<a href="https://github.com/jurakovic/runtime" target="_blank" rel="noopener">
jurakovic/runtime
</a>
{% endif %}
</div>
21 changes: 21 additions & 0 deletions custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

:root {
--md-text-font: "Segoe UI";
--md-text-font-family: "Segoe UI", "Segoe UI Variable Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.md-typeset {
font-size: .75rem;
}

.md-copyright {
font-size: .55rem;
}

[data-md-color-scheme="slate"] {
--md-default-bg-color: #1F1F1F;
}

[data-md-color-primary=black] .md-header {
background-color: #1F1F1F;
}
53 changes: 39 additions & 14 deletions docs/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@



<link rel="icon" href="/runtime/assets/images/favicon.png">
<link rel="icon" href="/runtime/favicon.svg">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.6.23">


Expand All @@ -34,14 +34,10 @@





<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>



<link rel="stylesheet" href="/runtime/custom.css">

<script>__md_scope=new URL("/runtime/",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>


Expand Down Expand Up @@ -69,7 +65,7 @@



<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="indigo">
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="white" data-md-color-accent="indigo">


<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
Expand All @@ -92,7 +88,7 @@
<a href="/runtime/." title="The Book of the Runtime" class="md-header__button md-logo" aria-label="The Book of the Runtime" data-md-component="logo">


<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2m10 7.5V9a2 2 0 0 0-2-2H9v10h4a2 2 0 0 0 2-2v-1.5c0-.8-.7-1.5-1.5-1.5.8 0 1.5-.7 1.5-1.5M13 15h-2v-2h2zm0-4h-2V9h2z"/></svg>

</a>
<label class="md-header__button md-icon" for="__drawer">
Expand Down Expand Up @@ -122,10 +118,10 @@



<input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="indigo" aria-label="Switch to dark mode" type="radio" name="__palette" id="__palette_0">
<input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="white" data-md-color-accent="indigo" aria-label="Switch to dark mode" type="radio" name="__palette" id="__palette_0">

<label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_1" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m17.75 4.09-2.53 1.94.91 3.06-2.63-1.81-2.63 1.81.91-3.06-2.53-1.94L12.44 4l1.06-3 1.06 3zm3.5 6.91-1.64 1.25.59 1.98-1.7-1.17-1.7 1.17.59-1.98L15.75 11l2.06-.05L18.5 9l.69 1.95zm-2.28 4.95c.83-.08 1.72 1.1 1.19 1.85-.32.45-.66.87-1.08 1.27C15.17 23 8.84 23 4.94 19.07c-3.91-3.9-3.91-10.24 0-14.14.4-.4.82-.76 1.27-1.08.75-.53 1.93.36 1.85 1.19-.27 2.86.69 5.83 2.89 8.02a9.96 9.96 0 0 0 8.02 2.89m-1.64 2.02a12.08 12.08 0 0 1-7.8-3.47c-2.17-2.19-3.33-5-3.49-7.82-2.81 3.14-2.7 7.96.31 10.98 3.02 3.01 7.84 3.12 10.98.31"/></svg>
</label>


Expand All @@ -135,7 +131,7 @@
<input class="md-option" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme="slate" data-md-color-primary="black" data-md-color-accent="indigo" aria-label="Switch to light mode" type="radio" name="__palette" id="__palette_1">

<label class="md-header__button md-icon" title="Switch to light mode" for="__palette_0" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 7a5 5 0 0 1 5 5 5 5 0 0 1-5 5 5 5 0 0 1-5-5 5 5 0 0 1 5-5m0 2a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0-7 2.39 3.42C13.65 5.15 12.84 5 12 5s-1.65.15-2.39.42zM3.34 7l4.16-.35A7.2 7.2 0 0 0 5.94 8.5c-.44.74-.69 1.5-.83 2.29zm.02 10 1.76-3.77a7.131 7.131 0 0 0 2.38 4.14zM20.65 7l-1.77 3.79a7.02 7.02 0 0 0-2.38-4.15zm-.01 10-4.14.36c.59-.51 1.12-1.14 1.54-1.86.42-.73.69-1.5.83-2.29zM12 22l-2.41-3.44c.74.27 1.55.44 2.41.44.82 0 1.63-.17 2.37-.44z"/></svg>
</label>


Expand Down Expand Up @@ -228,7 +224,7 @@
<a href="/runtime/." title="The Book of the Runtime" class="md-nav__button md-logo" aria-label="The Book of the Runtime" data-md-component="logo">


<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2m10 7.5V9a2 2 0 0 0-2-2H9v10h4a2 2 0 0 0 2-2v-1.5c0-.8-.7-1.5-1.5-1.5.8 0 1.5-.7 1.5-1.5M13 15h-2v-2h2zm0-4h-2V9h2z"/></svg>

</a>
The Book of the Runtime
Expand Down Expand Up @@ -760,6 +756,28 @@



<li class="md-nav__item">
<a href="/runtime/runtime-async-codegen/" class="md-nav__link">



<span class="md-ellipsis">
Runtime Async Codegen

</span>


</a>
</li>









<li class="md-nav__item">
<a href="/runtime/ilc-architecture/" class="md-nav__link">

Expand Down Expand Up @@ -955,12 +973,19 @@ <h1>404 - Not found</h1>
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">

<div class="md-copyright__highlight">
Unofficial documentation site. Not affiliated with Microsoft. Microsoft and .NET are trademarks of Microsoft Corporation.
</div>


Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
in <a href="https://github.com/jurakovic/runtime" target="_blank">jurakovic/runtime</a>
in
<a href="https://github.com/jurakovic/runtime" target="_blank" rel="noopener">
jurakovic/runtime
</a>

</div>

Expand Down
Loading