Skip to content

Commit a09564f

Browse files
Merge pull request #23 from encode/tweak-docs
Tweak docs
2 parents 8216930 + 1a601c6 commit a09564f

5 files changed

Lines changed: 21 additions & 8 deletions

File tree

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ Styling adaptations can be kept simple, such as customising the colour scheme, o
5050
1. Modify [the HTML templating](styling.md#templates) to customise the layout.
5151
2. Override or add [CSS and JavaScript](styling.md#statics) static assets.
5252

53-
## Compatability
53+
## Compatibility
5454

55-
*Work is planned to handle compatability for both [mkdocs 2.x](https://www.encode.io/mkdocs/) sites, and [mkdocs 1.x](https://www.mkdocs.org/) sites.*
55+
*Work is planned to handle compatibility for both [mkdocs 2.x](https://www.encode.io/mkdocs/) sites, and [mkdocs 1.x](https://www.mkdocs.org/) sites.*

docs/navigation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,17 @@ A standard documentation site...
7070
| `navigation.md` | `navigation/index.html` | `/navigation/` |
7171
| `styling.md` | `styling/index.html` | `/styling/` |
7272

73+
<br/>
74+
7375
Uppercase filenames and GitHub style document paths...
7476

7577
| **Markdown Page** | **HTML output** | **URL** |
7678
|-------------------|--------------------------|----------------|
7779
| `README.md` | `index.html` | `/` |
7880
| `ABOUT.md` | `about.html` | `/about/` |
7981

82+
<br/>
83+
8084
Documentation structure including subdirectories...
8185

8286
| **Markdown Page** | **HTML output** | **URL** |

docs/styling.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The base template for rendering markdown pages is **`templates/base.html`**.
2323
<head>
2424
<meta charset="utf-8">
2525
<meta name="viewport" content="width=device-width, initial-scale=1.0">
26-
<title>{{ config.mkdocs.title or page.title }}</title>
26+
<title>{{ nav.current.title or page.title }}{{ " - " ~ config.context.title if config.context.title }}</title>
2727
<link rel="icon" href="data:image/svg+xml,&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 100 100&quot;&gt;&lt;text y=&quot;.9em&quot; font-size=&quot;90&quot;&gt;{{ config.mkdocs.favicon or '📘' }}&lt;/text&gt;&lt;/svg&gt;">
2828
<link rel="stylesheet" href="{{ '/css/highlightjs.min.css' | url }}">
2929
<link rel="stylesheet" href="{{ '/css/highlightjs-copy.min.css' | url }}">
@@ -133,7 +133,7 @@ resources = [
133133
```toml
134134
[mkdocs]
135135
resources = [
136-
{url="https://github.com/lovelydinosaur/test/archive/refs/heads/main.zip"},
136+
{url="https://github.com/lovelydinosaur/mkdocs-theme/archive/refs/heads/main.zip"},
137137
{directory="docs"},
138138
]
139139
```
@@ -156,3 +156,5 @@ resources = [
156156
{directory="docs"},
157157
]
158158
```
159+
160+
<br/>

src/mkdocs/mkdocs.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import base64
12
import io
3+
import json
24
import pathlib
35
import posixpath
46
import typing
@@ -138,7 +140,8 @@ def __init__(self, url: str) -> None:
138140
self._topdir = ''
139141

140142
def load_paths(self) -> list[pathlib.Path]:
141-
r = httpx.get(self._url)
143+
r = httpx.get(self._url, follow_redirects=True)
144+
r.raise_for_status()
142145
b = io.BytesIO(r.content)
143146
with zipfile.ZipFile(b, 'r') as zip_ref:
144147
names = [
@@ -152,6 +155,7 @@ def load_paths(self) -> list[pathlib.Path]:
152155

153156
def read(self, path: pathlib.Path) -> bytes:
154157
r = httpx.get(self._url, follow_redirects=True)
158+
r.raise_for_status()
155159
b = io.BytesIO(r.content)
156160
with zipfile.ZipFile(b, 'r') as zip_ref:
157161
path = f"{self._topdir}/{path}" if self._topdir else path
@@ -223,11 +227,14 @@ class TemplateLoader(jinja2.BaseLoader):
223227
def __init__(self, templates: list[Template]):
224228
self.templates = templates
225229

230+
def uptodate(self):
231+
return False
232+
226233
def get_source(self, environment: jinja2.Environment, template: str):
227234
for t in self.templates:
228235
if t.name == template:
229236
source = t.read().decode('utf-8')
230-
return source, t.path, None
237+
return source, t.path, self.uptodate
231238
raise jinja2.TemplateNotFound(template)
232239

233240

src/mkdocs/theme/templates/base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<head>
33
<meta charset="utf-8">
44
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5-
<title>{{ nav.current.title or page.title or config.mkdocs.site_title }}</title>
6-
<link rel="icon" href="data:image/svg+xml,&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 100 100&quot;&gt;&lt;text y=&quot;.9em&quot; font-size=&quot;90&quot;&gt;{{ config.mkdocs.favicon or '📘' }}&lt;/text&gt;&lt;/svg&gt;">
5+
<title>{{ nav.current.title or page.title }}{{ " - " ~ config.context.title if config.context.title }}</title>
6+
<link rel="icon" href="data:image/svg+xml,&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 100 100&quot;&gt;&lt;text y=&quot;.9em&quot; font-size=&quot;90&quot;&gt;{{ config.context.favicon or '📘' }}&lt;/text&gt;&lt;/svg&gt;">
77
<link rel="stylesheet" href="{{ '/css/highlightjs.min.css' | url }}">
88
<link rel="stylesheet" href="{{ '/css/highlightjs-copy.min.css' | url }}">
99
<link rel="stylesheet" href="{{ '/css/theme.css' | url }}">

0 commit comments

Comments
 (0)