mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Better titles & descriptions
This commit is contained in:
parent
da76bd7047
commit
22a389d0ba
|
@ -2,11 +2,11 @@
|
|||
<html lang="en">
|
||||
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Django REST framework - APIs made easy.</title>
|
||||
<title>{{ title }}</title>
|
||||
<link href="{{ base_url }}/img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<meta name="description" content="{{ description }}">
|
||||
<meta name="author" content="Tom Christie">
|
||||
|
||||
<!-- Le styles -->
|
||||
<link href="{{ base_url }}/css/prettify.css" rel="stylesheet">
|
||||
|
|
12
mkdocs.py
12
mkdocs.py
|
@ -57,24 +57,36 @@ for (dirpath, dirnames, filenames) in os.walk(docs_dir):
|
|||
|
||||
toc = ''
|
||||
text = open(path, 'r').read().decode('utf-8')
|
||||
main_title = None
|
||||
description = 'Django, API, REST'
|
||||
for line in text.splitlines():
|
||||
if line.startswith('# '):
|
||||
title = line[2:].strip()
|
||||
template = main_header
|
||||
description = description + ', ' + title
|
||||
elif line.startswith('## '):
|
||||
title = line[3:].strip()
|
||||
template = sub_header
|
||||
else:
|
||||
continue
|
||||
|
||||
if not main_title:
|
||||
main_title = title
|
||||
anchor = title.lower().replace(' ', '-').replace(':-', '-').replace("'", '').replace('?', '').replace('.', '')
|
||||
template = template.replace('{{ title }}', title)
|
||||
template = template.replace('{{ anchor }}', anchor)
|
||||
toc += template + '\n'
|
||||
|
||||
if filename == 'index.md':
|
||||
main_title = 'Django REST framework - APIs made easy'
|
||||
else:
|
||||
main_title = 'Django REST framework - ' + main_title
|
||||
|
||||
content = markdown.markdown(text, ['headerid'])
|
||||
|
||||
output = page.replace('{{ content }}', content).replace('{{ toc }}', toc).replace('{{ base_url }}', base_url).replace('{{ suffix }}', suffix).replace('{{ index }}', index)
|
||||
output = output.replace('{{ title }}', main_title)
|
||||
output = output.replace('{{ description }}', description)
|
||||
output = output.replace('{{ page_id }}', filename[:-3])
|
||||
output = re.sub(r'a href="([^"]*)\.md"', r'a href="\1%s"' % suffix, output)
|
||||
output = re.sub(r'<pre><code>:::bash', r'<pre class="prettyprint lang-bsh">', output)
|
||||
|
|
Loading…
Reference in New Issue
Block a user