mirror of
https://github.com/mkdocs/mkdocs.git
synced 2026-03-27 09:58:31 +07:00
Deployed 40e7bb0 with MkDocs version: 0.14.0
This commit is contained in:
0
__init__.py
Normal file
0
__init__.py
Normal file
BIN
__init__.pyc
Normal file
BIN
__init__.pyc
Normal file
Binary file not shown.
BIN
__pycache__/__init__.cpython-33.pyc
Normal file
BIN
__pycache__/__init__.cpython-33.pyc
Normal file
Binary file not shown.
BIN
__pycache__/__init__.cpython-34.pyc
Normal file
BIN
__pycache__/__init__.cpython-34.pyc
Normal file
Binary file not shown.
@@ -342,5 +342,5 @@ for a number of common hosts, see the <a href="./user-guide/deploying-your-docs/
|
||||
|
||||
<!--
|
||||
MkDocs version : 0.14.0
|
||||
Build Date UTC : 2015-06-25 06:44:56.906000
|
||||
Build Date UTC : 2015-06-30 20:43:28.774516
|
||||
-->
|
||||
|
||||
16
sitemap.xml
16
sitemap.xml
@@ -4,7 +4,7 @@
|
||||
|
||||
<url>
|
||||
<loc>http://www.mkdocs.org/</loc>
|
||||
<lastmod>2015-06-25</lastmod>
|
||||
<lastmod>2015-06-30</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
@@ -13,25 +13,25 @@
|
||||
|
||||
<url>
|
||||
<loc>http://www.mkdocs.org/user-guide/configuration/</loc>
|
||||
<lastmod>2015-06-25</lastmod>
|
||||
<lastmod>2015-06-30</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.mkdocs.org/user-guide/deploying-your-docs/</loc>
|
||||
<lastmod>2015-06-25</lastmod>
|
||||
<lastmod>2015-06-30</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.mkdocs.org/user-guide/styling-your-docs/</loc>
|
||||
<lastmod>2015-06-25</lastmod>
|
||||
<lastmod>2015-06-30</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.mkdocs.org/user-guide/writing-your-docs/</loc>
|
||||
<lastmod>2015-06-25</lastmod>
|
||||
<lastmod>2015-06-30</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
@@ -41,19 +41,19 @@
|
||||
|
||||
<url>
|
||||
<loc>http://www.mkdocs.org/about/contributing/</loc>
|
||||
<lastmod>2015-06-25</lastmod>
|
||||
<lastmod>2015-06-30</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.mkdocs.org/about/license/</loc>
|
||||
<lastmod>2015-06-25</lastmod>
|
||||
<lastmod>2015-06-30</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.mkdocs.org/about/release-notes/</loc>
|
||||
<lastmod>2015-06-25</lastmod>
|
||||
<lastmod>2015-06-30</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
|
||||
629
user-guide/custom-themes/index.html
Normal file
629
user-guide/custom-themes/index.html
Normal file
@@ -0,0 +1,629 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<meta name="author" content="Tom Christie & Dougal Matthews">
|
||||
<link rel="canonical" href="http://www.mkdocs.org/user-guide/custom-themes/">
|
||||
<link rel="shortcut icon" href="../../img/favicon.ico">
|
||||
|
||||
<title>Custom Themes - MkDocs</title>
|
||||
|
||||
<link href="../../css/bootstrap-custom.min.css" rel="stylesheet">
|
||||
<link href="../../css/font-awesome-4.0.3.css" rel="stylesheet">
|
||||
<link href="../../css/base.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../../css/highlight.css">
|
||||
<link href="../../css/extra.css" rel="stylesheet">
|
||||
|
||||
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-27795084-5', 'mkdocs.org');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
|
||||
<!-- Collapsed navigation -->
|
||||
<div class="navbar-header">
|
||||
|
||||
<!-- Expander button -->
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
|
||||
|
||||
<!-- Main title -->
|
||||
<a class="navbar-brand" href="../..">MkDocs</a>
|
||||
</div>
|
||||
|
||||
<!-- Expanded navigation -->
|
||||
<div class="navbar-collapse collapse">
|
||||
|
||||
<!-- Main navigation -->
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li class="dropdown active">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">User Guide <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
|
||||
<li >
|
||||
<a href="../writing-your-docs/">Writing Your Docs</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li >
|
||||
<a href="../styling-your-docs/">Styling Your Docs</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li >
|
||||
<a href="../configuration/">Configuration</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li >
|
||||
<a href="../deploying-your-docs/">Deploying Your Docs</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li class="active">
|
||||
<a href="./">Custom Themes</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">About <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
|
||||
<li >
|
||||
<a href="../../about/release-notes/">Release Notes</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li >
|
||||
<a href="../../about/contributing/">Contributing</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li >
|
||||
<a href="../../about/license/">License</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="#" data-toggle="modal" data-target="#mkdocs_search_modal">
|
||||
<i class="fa fa-search"></i> Search
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a rel="next" href="../deploying-your-docs/">
|
||||
<i class="fa fa-arrow-left"></i> Previous
|
||||
</a>
|
||||
</li>
|
||||
<li >
|
||||
<a rel="prev" href="../../about/release-notes/">
|
||||
Next <i class="fa fa-arrow-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<li>
|
||||
<a href="https://github.com/mkdocs/mkdocs/">
|
||||
|
||||
<i class="fa fa-github"></i>
|
||||
|
||||
GitHub
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="col-md-3"><div class="bs-sidebar hidden-print affix well" role="complementary">
|
||||
<ul class="nav bs-sidenav">
|
||||
|
||||
<li class="main active"><a href="#custom-themes">Custom themes</a></li>
|
||||
|
||||
<li><a href="#creating-a-custom-theme">Creating a custom theme</a></li>
|
||||
|
||||
<li><a href="#basic-theme">Basic theme</a></li>
|
||||
|
||||
<li><a href="#template-variables">Template Variables</a></li>
|
||||
|
||||
<li><a href="#search-and-themes">Search and themes</a></li>
|
||||
|
||||
<li><a href="#packaging-themes">Packaging Themes</a></li>
|
||||
|
||||
|
||||
</ul>
|
||||
</div></div>
|
||||
<div class="col-md-9" role="main">
|
||||
|
||||
<h1 id="custom-themes">Custom themes<a class="headerlink" href="#custom-themes" title="Permanent link"></a></h1>
|
||||
<p>A guide to creating and distributing custom themes.</p>
|
||||
<hr />
|
||||
<p>When creating a new theme, you can either follow the steps in this guide to
|
||||
create one from scratch or you can download the <code>mkdocs-basic-theme</code> as a
|
||||
basic, yet complete, theme with all the boilerplate required. <strong>You can find
|
||||
this base theme on <a href="https://github.com/mkdocs/mkdocs-basic-theme">GitHub</a></strong>.
|
||||
It contains detailed comments in the code to describe the different features
|
||||
and their usage.</p>
|
||||
<h2 id="creating-a-custom-theme">Creating a custom theme<a class="headerlink" href="#creating-a-custom-theme" title="Permanent link"></a></h2>
|
||||
<p>The bare minimum required for a custom theme is a <code>base.html</code> <a href="http://jinja.pocoo.org/docs/dev/">Jinja2
|
||||
template</a> file. This should be placed in a directory which will be the
|
||||
<code>theme_dir</code> and it should be created next to the <code>mkdocs.yml</code> configuration
|
||||
file. Within <code>mkdocs.yml</code>, specify the <code>theme_dir</code> option and set it to the
|
||||
name of the directory containing <code>base.html</code>. For example, given this example
|
||||
project layout:</p>
|
||||
<pre><code>mkdocs.yml
|
||||
docs/
|
||||
index.md
|
||||
about.md
|
||||
custom_theme/
|
||||
base.html
|
||||
...
|
||||
</code></pre>
|
||||
<p>You would include the following setting to use the custom theme directory:</p>
|
||||
<pre><code>theme_dir: 'custom_theme'
|
||||
</code></pre>
|
||||
<p>If used in combination with the <code>theme</code> configuration value a custom theme can
|
||||
be used to replace only specific parts of a built-in theme. For example, with
|
||||
the above layout and if you set <code>theme: mkdocs</code> then the <code>base.html</code> file
|
||||
would replace that in the theme but otherwise it would remain the same. This
|
||||
is useful if you want to make small adjustments to an existing theme.</p>
|
||||
<h2 id="basic-theme">Basic theme<a class="headerlink" href="#basic-theme" title="Permanent link"></a></h2>
|
||||
<p>The simplest <code>base.html</code> file is the following:</p>
|
||||
<pre><code class="django"><!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% if page_title %}{{ page_title }} - {% endif %}{{ site_name }}</title>
|
||||
</head>
|
||||
<body>
|
||||
{{ content }}
|
||||
</body>
|
||||
</html>
|
||||
</code></pre>
|
||||
|
||||
<p>Article content from each page specified in <code>mkdocs.yml</code> is inserted using the
|
||||
<code>{{ content }}</code> tag. Stylesheets and scripts can be brought into this theme as
|
||||
with a normal HTML file. Navbars and tables of contents can also be generated
|
||||
and included automatically, through the <code>nav</code> and <code>toc</code> objects, respectively.
|
||||
If you wish to write your own theme, it is recommended to start with one of
|
||||
the <a href="https://github.com/mkdocs/mkdocs/tree/master/mkdocs/themes">built-in themes</a> and modify it accordingly.</p>
|
||||
<h2 id="template-variables">Template Variables<a class="headerlink" href="#template-variables" title="Permanent link"></a></h2>
|
||||
<p>Each template in a theme is built with a template context. These are the
|
||||
variables that are available to themes. The context varies depending on the
|
||||
template that is being built. At the moment templates are either built with
|
||||
the global context or with a page specific context. The global context is used
|
||||
for HTML pages that don't represent an individual Markdown document, for
|
||||
example a 404.html page or search.html.</p>
|
||||
<h3 id="global-context">Global Context<a class="headerlink" href="#global-context" title="Permanent link"></a></h3>
|
||||
<p>The following variables in the context map directly the <a href="../configuration/">configuration options
|
||||
</a>.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Variable Name</th>
|
||||
<th>Configuration name</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>site_name</td>
|
||||
<td><a href="../configuration/#site_name">site_name</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>site_author</td>
|
||||
<td><a href="../configuration/#site_author">site_author</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>favicon</td>
|
||||
<td><a href="../configuration/#site_favicon">site_favicon</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>page_description</td>
|
||||
<td><a href="../configuration/#site_description">site_description</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>repo_url</td>
|
||||
<td><a href="../configuration/#repo_url">repo_url</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>repo_name</td>
|
||||
<td><a href="../configuration/#repo_name">repo_name</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>site_url</td>
|
||||
<td><a href="../configuration/#site_url">site_url</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>extra_css</td>
|
||||
<td><a href="../configuration/#extra_css">extra_css</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>extra_javascript</td>
|
||||
<td><a href="../configuration/#extra_javascript">extra_javascript</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>extra</td>
|
||||
<td><a href="../configuration/#extra">extra</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>include_nav</td>
|
||||
<td><a href="../configuration/#include_nav">include_nav</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>include_next_prev</td>
|
||||
<td><a href="../configuration/#include_next_prev">include_next_prev</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>copyright</td>
|
||||
<td><a href="../configuration/#copyright">copyright</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>google_analytics</td>
|
||||
<td><a href="../configuration/#google_analytics">google_analytics</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>The following variables provide information about the navigation and location.</p>
|
||||
<h4 id="nav">nav<a class="headerlink" href="#nav" title="Permanent link"></a></h4>
|
||||
<p>The <code>nav</code> variable is used to create the navigation for the documentation.
|
||||
Following is a basic usage example which outputs the first and second level
|
||||
navigation as a nested list.</p>
|
||||
<pre><code class="django"><ul>
|
||||
{% for nav_item in nav %}
|
||||
{% if nav_item.children %}
|
||||
<li>{{ nav_item.title }}
|
||||
<ul>
|
||||
{% for nav_item in nav_item.children %}
|
||||
<li class="{% if nav_item.active%}current{%endif%}">
|
||||
<a href="{{ nav_item.url }}">{{ nav_item.title }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="{% if nav_item.active%}current{%endif%}">
|
||||
<a href="{{ nav_item.url }}">{{ nav_item.title }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</code></pre>
|
||||
|
||||
<h4 id="base_url">base_url<a class="headerlink" href="#base_url" title="Permanent link"></a></h4>
|
||||
<p>The <code>base_url</code> provides a relative path to the root of the MkDocs project.
|
||||
This makes it easy to include links to static assets in your theme. For
|
||||
example, if your theme includes a <code>js</code> folder, to include <code>theme.js</code> from that
|
||||
folder on all pages you would do this:</p>
|
||||
<pre><code class="django"><script src="{{ base_url }}/js/theme.js"></script>
|
||||
</code></pre>
|
||||
|
||||
<h4 id="homepage_url">homepage_url<a class="headerlink" href="#homepage_url" title="Permanent link"></a></h4>
|
||||
<p>Provides a relative path to the documentation homepage.</p>
|
||||
<h4 id="mkdocs_version">mkdocs_version<a class="headerlink" href="#mkdocs_version" title="Permanent link"></a></h4>
|
||||
<p>Contains the current MkDocs version.</p>
|
||||
<h4 id="build_date_utc">build_date_utc<a class="headerlink" href="#build_date_utc" title="Permanent link"></a></h4>
|
||||
<p>A Python datetime object that represents the date and time the documentation
|
||||
was built in UTC. This is useful for showing how recently the documentation
|
||||
was updated.</p>
|
||||
<h3 id="page-context">Page Context<a class="headerlink" href="#page-context" title="Permanent link"></a></h3>
|
||||
<p>The page context includes all of the above Global context and the following
|
||||
additional variables.</p>
|
||||
<h4 id="page_title">page_title<a class="headerlink" href="#page_title" title="Permanent link"></a></h4>
|
||||
<p>Contains the Title for the current page.</p>
|
||||
<h4 id="page_description">page_description<a class="headerlink" href="#page_description" title="Permanent link"></a></h4>
|
||||
<p>Contains the description for the current page on the homepage, it is blank on
|
||||
other pages.</p>
|
||||
<h4 id="content">content<a class="headerlink" href="#content" title="Permanent link"></a></h4>
|
||||
<p>The rendered Markdown as HTML, this is the contents of the documentation.</p>
|
||||
<h4 id="toc">toc<a class="headerlink" href="#toc" title="Permanent link"></a></h4>
|
||||
<p>An object representing the Table of contents for a page. Displaying the table
|
||||
of contents as a simple list can be achieved like this.</p>
|
||||
<pre><code class="django"><ul>
|
||||
{% for toc_item in toc %}
|
||||
<li><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
|
||||
{% for toc_item in toc_item.children %}
|
||||
<li><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</code></pre>
|
||||
|
||||
<h4 id="meta">meta<a class="headerlink" href="#meta" title="Permanent link"></a></h4>
|
||||
<p>A mapping of the metadata included at the top of the markdown page. In this
|
||||
example we define a <code>source</code> property above the page title.</p>
|
||||
<pre><code class="no-highlight">source: generics.py
|
||||
mixins.py
|
||||
|
||||
# Page title
|
||||
|
||||
Content...
|
||||
</code></pre>
|
||||
|
||||
<p>A template can access this metadata for the page with the <code>meta.source</code>
|
||||
variable. This could then be used to link to source files related to the
|
||||
documentation page.</p>
|
||||
<pre><code class="django">{% for filename in meta.source %}
|
||||
<a class="github" href="https://github.com/.../{{ filename }}">
|
||||
<span class="label label-info">{{ filename }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</code></pre>
|
||||
|
||||
<h4 id="canonical_url">canonical_url<a class="headerlink" href="#canonical_url" title="Permanent link"></a></h4>
|
||||
<p>The full, canonical URL to the current page. This includes the site_url from
|
||||
the configuration.</p>
|
||||
<h4 id="current_page">current_page<a class="headerlink" href="#current_page" title="Permanent link"></a></h4>
|
||||
<p>The page object for the current page. The page path and url properties can be
|
||||
displayed like this.</p>
|
||||
<pre><code class="django"><h1>{{ current_page.title }}</h1>
|
||||
<p> This page is at {{ current_page.url }}</p>
|
||||
</code></pre>
|
||||
|
||||
<h4 id="previous_page">previous_page<a class="headerlink" href="#previous_page" title="Permanent link"></a></h4>
|
||||
<p>The page object for the previous page. The usage is the same as for
|
||||
<code>current_page</code>.</p>
|
||||
<h4 id="next_page">next_page<a class="headerlink" href="#next_page" title="Permanent link"></a></h4>
|
||||
<p>The page object for the next page.The usage is the same as for <code>current_page</code>.</p>
|
||||
<h3 id="extra-context">Extra Context<a class="headerlink" href="#extra-context" title="Permanent link"></a></h3>
|
||||
<p>Additional variables can be passed to the template with the
|
||||
<a href="../configuration/#extra"><code>extra</code></a> configuration option. This is a set of key value
|
||||
pairs that can make custom templates far more flexible.</p>
|
||||
<p>For example, this could be used to include the project version of all pages
|
||||
and a list of links related to the project. This can be achieved with the
|
||||
following <code>extra</code> configuration:</p>
|
||||
<pre><code class="yaml">extra:
|
||||
version: 0.13.0
|
||||
links:
|
||||
- https://github.com/mkdocs
|
||||
- https://docs.readthedocs.org/en/latest/builds.html#mkdocs
|
||||
- http://www.mkdocs.org/
|
||||
</code></pre>
|
||||
|
||||
<p>And then displayed with this HTML in the custom theme.</p>
|
||||
<pre><code class="django">{{ config.extra.version }}
|
||||
|
||||
{% if config.extra.links %}
|
||||
<ul>
|
||||
{% for link in config.extra.links %}
|
||||
<li>{{ link }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</code></pre>
|
||||
|
||||
<h2 id="search-and-themes">Search and themes<a class="headerlink" href="#search-and-themes" title="Permanent link"></a></h2>
|
||||
<p>As of MkDocs <code>0.13</code> client side search support has been added to MkDocs with
|
||||
<a href="http://lunrjs.com/">Lunr.js</a>.</p>
|
||||
<p>Search can either be added to every page in the theme or to a dedicated
|
||||
template which must be named <code>search.html</code>. The search template will be build
|
||||
with the same name and can be viewable with <code>mkdocs serve</code> at
|
||||
<code>http://localhost:8000/search.html</code>. An example of the two different
|
||||
approaches can be seen by comparing the <code>mkdocs</code> and <code>readthedocs</code> themes.</p>
|
||||
<p>The following HTML needs to be added to the theme so the JavaScript is loaded
|
||||
for Lunr.js.</p>
|
||||
<pre><code class="django"><script>var base_url = '{{ base_url }}';</script>
|
||||
<script data-main="{{ base_url }}/mkdocs/js/search.js" src="{{ base_url }}/mkdocs/js/require.js"></script>
|
||||
</code></pre>
|
||||
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>The above JavaScript will download the search index, for larger
|
||||
documentation projects this can be a heavy operation. In those cases, it
|
||||
is suggested that you either use the <code>search.html</code> approach to only
|
||||
include search on one page or load the JavaScript on an event like a form
|
||||
submit.</p>
|
||||
</div>
|
||||
<p>This loads the JavaScript and sets a global variable <code>base_url</code> which allows
|
||||
the JavaScript to make the links relative to the current page. The above
|
||||
JavaScript, with the following HTML in a <code>search.html</code> template will add a
|
||||
full search implementation to your theme.</p>
|
||||
<pre><code class="django"><h1 id="search">Search Results</h1>
|
||||
|
||||
<form action="search.html">
|
||||
<input name="q" id="mkdocs-search-query" type="text" class="search_input search-query ui-autocomplete-input" placeholder="Search the Docs" autocomplete="off">
|
||||
</form>
|
||||
|
||||
<div id="mkdocs-search-results">
|
||||
Sorry, page not found.
|
||||
</div>
|
||||
</code></pre>
|
||||
|
||||
<p>This works by looking for the specific ID's used in the above HTML. The input
|
||||
for the user to type the search query must have the ID <code>mkdocs-search-query</code>
|
||||
and <code>mkdocs-search-results</code> is the directory where the results will be placed.</p>
|
||||
<h2 id="packaging-themes">Packaging Themes<a class="headerlink" href="#packaging-themes" title="Permanent link"></a></h2>
|
||||
<p>MkDocs makes use of <a href="https://packaging.python.org/en/latest/">Python packaging</a> to distribute themes. This comes with a
|
||||
few requirements.</p>
|
||||
<p>To see an example of a package containing one theme, see the <a href="http://mkdocs.github.io/mkdocs-bootstrap/">MkDocs Bootstrap
|
||||
theme</a> and to see a package that contains many themes, see the <a href="http://mkdocs.github.io/mkdocs-bootswatch/">MkDocs
|
||||
Bootswatch theme</a>.</p>
|
||||
<h3 id="package-layout">Package Layout<a class="headerlink" href="#package-layout" title="Permanent link"></a></h3>
|
||||
<p>The following layout is recommended for themes. Two files at the top level
|
||||
directory called <code>MANIFEST.in</code> amd <code>setup.py</code>. Then a directory with the name
|
||||
of your theme and containing a <code>base.html</code> file and a <code>__init__.py</code>.</p>
|
||||
<pre><code class="no-highlight">.
|
||||
|-- MANIFEST.in
|
||||
|-- theme_name
|
||||
| |-- base.html
|
||||
| |-- __init__.py
|
||||
`-- setup.py
|
||||
</code></pre>
|
||||
|
||||
<p>The <code>MANIFEST.in</code> file should contain the following contents but with
|
||||
theme_name updated and any extra file extensions added to the include.</p>
|
||||
<pre><code class="no-highlight">recursive-include theme_name *.ico *.js *.css *.png *.html *.eot *.svg *.ttf *.woff
|
||||
recursive-exclude * __pycache__
|
||||
recursive-exclude * *.py[co]
|
||||
</code></pre>
|
||||
|
||||
<p>The <code>setup.py</code> should include the following text with the modifications
|
||||
described below.</p>
|
||||
<pre><code class="python">from setuptools import setup, find_packages
|
||||
|
||||
VERSION = '0.0.1'
|
||||
|
||||
|
||||
setup(
|
||||
name="mkdocs-themename",
|
||||
version=VERSION,
|
||||
url='',
|
||||
license='',
|
||||
description='',
|
||||
author='',
|
||||
author_email='',
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
entry_points={
|
||||
'mkdocs.themes': [
|
||||
'themename = theme_name',
|
||||
]
|
||||
},
|
||||
zip_safe=False
|
||||
)
|
||||
</code></pre>
|
||||
|
||||
<p>Fill in the URL, license, description, author and author email address.</p>
|
||||
<p>The name should follow the convention <code>mkdocs-themename</code> (like <code>mkdocs-
|
||||
bootstrap</code> and <code>mkdocs-bootswatch</code>), starting with MkDocs, using hyphens to
|
||||
separate words and including the name of your theme.</p>
|
||||
<p>Most of the rest of the file can be left unedited. The last section we need to
|
||||
change is the entry_points. This is how MkDocs finds the theme(s) you are
|
||||
including in the package. The name on the left is the one that users will use
|
||||
in their mkdocs.yml and the one on the right is the directory containing your
|
||||
theme files.</p>
|
||||
<p>The directory you created at the start of this section with the base.html file
|
||||
should contain all of the other theme files. The minimum requirement is that
|
||||
it includes a <code>base.html</code> for the theme. It <strong>must</strong> also include a
|
||||
<code>__init__.py</code> file which should be empty, this file tells Python that the
|
||||
directory is a package.</p>
|
||||
<h3 id="distributing-themes">Distributing Themes<a class="headerlink" href="#distributing-themes" title="Permanent link"></a></h3>
|
||||
<p>With the above changes, your theme should now be ready to install. This can be
|
||||
done with pip, using <code>pip install .</code> if you are still in the same directory as
|
||||
the setup.py.</p>
|
||||
<p>Most Python packages, including MkDocs, are distributed on PyPI. To do this,
|
||||
you should run the following command.</p>
|
||||
<pre><code class="no-highlight">python setup.py register
|
||||
</code></pre>
|
||||
|
||||
<p>If you don't have an account setup, you should be prompted to create one.</p>
|
||||
<p>For a much more detailed guide, see the official Python packaging
|
||||
documentation for <a href="">Packaging and Distributing Projects</a>.</p>
|
||||
<p>https://packaging.python.org/en/latest/distributing.html</p></div>
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="col-md-12">
|
||||
<hr>
|
||||
|
||||
<p>Copyright © 2014 <a href="https://twitter.com/_tomchristie">Tom Christie</a>, <a href="http://www.dougalmatthews.com/">Dougal Matthews</a>.</p>
|
||||
|
||||
<p>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</p>
|
||||
</footer>
|
||||
|
||||
<script src="../../js/jquery-1.10.2.min.js"></script>
|
||||
<script src="../../js/bootstrap-3.0.3.min.js"></script>
|
||||
<script src="../../js/highlight.pack.js"></script>
|
||||
<script>var base_url = '../..';</script>
|
||||
<script data-main="../../mkdocs/js/search.js" src="../../mkdocs/js/require.js"></script>
|
||||
<script src="../../js/base.js"></script>
|
||||
|
||||
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="Search Modal" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title" id="exampleModalLabel">Search</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
From here you can search these documents. Enter
|
||||
your search terms below.
|
||||
</p>
|
||||
<form role="form">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="Search..." id="mkdocs-search-query">
|
||||
</div>
|
||||
</form>
|
||||
<div id="mkdocs-search-results"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user