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
Binary file added docs/img/codercat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/styling.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The base template for rendering is `templates/base.html`:

You can override this template locally and adapt it to make layout changes.

## Media assets
## Media

The default theme includes the following assets:

Expand Down
6 changes: 3 additions & 3 deletions docs/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ These are the elements outlined in John Gruber’s original design document. All

## Link

[About](ABOUT.md)
[Homepage](index.md)

## Image

![calt text](img/codercat.jpg)
![coder cat](img/codercat.png)

## Table

Expand Down Expand Up @@ -103,7 +103,7 @@ Here's a sentence with a footnote. [^1]

`@octocat :+1: This PR looks great - it's ready to merge! :shipit:`

@octocat :+1: This PR looks great - it's ready to merge! :shipit:
@octocat :+1: This PR looks great :heart: - it's ready to merge! :shipit:

### Task List

Expand Down
25 changes: 6 additions & 19 deletions src/mkdocs/mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ def read(self, path: pathlib.Path) -> bytes:
"""
return ''

def name(self) -> str:
return ''


class Directory(Handler):
"""
Expand All @@ -78,9 +75,6 @@ def load_paths(self) -> list[pathlib.Path]:
def read(self, path: pathlib.Path) -> bytes:
return self._dir.joinpath(path).read_bytes()

def name(self) -> str:
return 'docs'

def __repr__(self):
return f'<Directory {self._dir_repr}>'

Expand Down Expand Up @@ -112,9 +106,6 @@ def load_paths(self) -> list[pathlib.Path]:
def read(self, path: pathlib.Path) -> bytes:
return self._files.joinpath(path).read_bytes()

def name(self) -> str:
return 'theme'

def __repr__(self):
return f'<Package {self._pkg!r}>'

Expand All @@ -137,7 +128,7 @@ def read(self) -> bytes:
return self.handler.read(self.path)

def __repr__(self) -> str:
return f'<Resource {self.url!r} {self.path.as_posix()!r} [{self.handler.name()}]>'
return f'<Resource {self.url!r} {self.path.as_posix()!r}>'


class Template:
Expand All @@ -150,7 +141,7 @@ def read(self) -> bytes:
return self.handler.read(self.path)

def __repr__(self) -> str:
return f'<Template {self.path.as_posix()!r} [{self.handler.name()}]>'
return f'<Template {self.name!r}>'


class TemplateLoader(jinja2.BaseLoader):
Expand Down Expand Up @@ -194,9 +185,6 @@ def path_to_url(self, path: pathlib.Path) -> str:
# 'css/styles.css' -> '/css/styles.css'
return pathlib.Path('/').joinpath(path).as_posix()

def log(self, msg: str) -> None:
print(msg)

def load_config(self, filename: str) -> dict:
path = pathlib.Path(filename)
if not path.exists():
Expand Down Expand Up @@ -230,10 +218,10 @@ def load_config(self, filename: str) -> dict:
# {'title': 'Themes & styling', 'path': 'styling.md'},
# ],
},
# 'handlers': {
# 'theme': {'type': 'mkdocs.Package', 'pkg': 'mkdocs:theme'}
# 'docs': {'type': 'mkdocs.FileSystem', 'dir': 'docs'}
# },
# 'handlers': [
# {'type': 'mkdocs.Package', 'pkg': 'mkdocs:theme'}
# {'type': 'mkdocs.Directory', 'dir': 'docs'}
# ],
'markdown': {
'extensions': {
'fenced_code',
Expand Down Expand Up @@ -329,7 +317,6 @@ def build(self):
for resource in resources:
output = self.render(resource, resources, config, env, md)
build_path = buildpath.joinpath(resource.output_path)
self.log(build_path)
build_path.parent.mkdir(parents=True, exist_ok=True)
build_path.write_bytes(output)

Expand Down
21 changes: 16 additions & 5 deletions src/mkdocs/rewrite_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,22 @@ def run(self, root):
ctx = page_context.get()
links = []
idx = 0
key = ''
link = ''

for el in root.iter('a'):
href = el.get('href')
if href:
url = httpx.URL(href)
for el in root.iter():
if el.tag == 'a':
key = 'href'
link = el.get(key)
elif el.tag == 'img':
key = 'src'
link = el.get(key)
else:
key = ''
link = ''

if link:
url = httpx.URL(link)
if url.is_relative_url and url._uri_reference.path:
from_path = ctx.path
to_path = ctx.path.parent.joinpath(url.path)
Expand All @@ -46,7 +57,7 @@ def run(self, root):
rewrite += f'?{url.query}'
if url.fragment:
rewrite += f'#{url.fragment}'
el.set('href', rewrite)
el.set(key, rewrite)
links.append({"title": el.text, "url": rewrite})

if from_url == to_url:
Expand Down
1 change: 1 addition & 0 deletions src/mkdocs/short_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'bug': '🐛',
'thinking': '🤔',
'eyes': '👀',
'shipit': '🚢',
}


Expand Down