mirror of
https://github.com/mkdocs/mkdocs.git
synced 2026-03-27 09:58:31 +07:00
Add include_nav and include_next_prev
This commit is contained in:
@@ -126,6 +126,8 @@ def get_context(page, content, nav, toc, meta, config):
|
||||
'extra_css': config['extra_css'],
|
||||
'extra_javascript': config['extra_javascript'],
|
||||
|
||||
'include_nav': config['include_nav'],
|
||||
'include_next_prev': config['include_next_prev'],
|
||||
'include_search': config['include_search'],
|
||||
}
|
||||
|
||||
@@ -166,12 +168,10 @@ def build_pages(config):
|
||||
utils.write_file(output_content.encode('utf-8'), output_path)
|
||||
|
||||
|
||||
def build(config):
|
||||
def build(config, live_server=False):
|
||||
"""
|
||||
Perform a full site build.
|
||||
"""
|
||||
print "Building documentation to directory: %s" % config['site_dir']
|
||||
if not live_server:
|
||||
print "Building documentation to directory: %s" % config['site_dir']
|
||||
utils.copy_media_files(config['theme_dir'], config['site_dir'])
|
||||
|
||||
@@ -20,16 +20,35 @@ DEFAULT_CONFIG = {
|
||||
'site_dir': 'site',
|
||||
'theme_dir': None,
|
||||
|
||||
# The address on which to serve the livereloading docs servers.
|
||||
'dev_addr': '127.0.0.1:8000',
|
||||
|
||||
# If `True`, use `<page_name>/index.hmtl` style files with hyperlinks to the directory.
|
||||
# If `False`, use `<page_name>.html style file with hyperlinks to the file.
|
||||
# True generates nicer URLs, but False is useful if browsing the output on a filesystem.
|
||||
'use_direcory_urls': True,
|
||||
|
||||
# Specify a link to the project source repo to be included
|
||||
# in the documentation pages.
|
||||
'repo_url': None,
|
||||
|
||||
# A name to use for the link to the project source repo.
|
||||
# Default: If repo_url is unset then None, otherwise
|
||||
# "GitHub" or "Bitbucket" for known url or Hostname for unknown urls.
|
||||
'repo_name': None,
|
||||
|
||||
# Specify which css or javascript files from the docs
|
||||
# directionary should be additionally included in the site.
|
||||
# Default: List of all .css and .js files in the docs dir.
|
||||
'extra_css': None,
|
||||
'extra_javascript': None,
|
||||
|
||||
# These are not yet supported...
|
||||
# Determine if the site should include the nav and next/prev elements.
|
||||
# Default: True if the site has more than one page, False otherwise.
|
||||
'include_nav': None,
|
||||
'include_next_prev': None,
|
||||
|
||||
# To Do
|
||||
'include_search': False,
|
||||
'include_404': False,
|
||||
'include_sitemap': False
|
||||
@@ -97,4 +116,21 @@ def validate_config(user_config):
|
||||
else:
|
||||
config['repo_name'] = repo_host.split('.')[0].title()
|
||||
|
||||
if config['include_next_prev'] is None:
|
||||
config['include_next_prev'] = len(config['pages']) > 1
|
||||
|
||||
if config['include_nav'] is None:
|
||||
config['include_nav'] = len(config['pages']) > 1
|
||||
|
||||
# To Do:
|
||||
|
||||
# The docs dir must exist.
|
||||
# The theme dir must exist.
|
||||
# Ensure 'theme' is one of 'mkdocs', 'readthedocs', 'custom'
|
||||
# A homepage 'index' must exist.
|
||||
# The theme 'base.html' file must exist.
|
||||
# Cannot set repo_name without setting repo_url.
|
||||
# Cannot set 'include_next_prev: true' when only one page exists.
|
||||
# Cannot set 'include_nav: true' when only one page exists.
|
||||
|
||||
return config
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
<!-- Collapsed navigation -->
|
||||
<div class="navbar-header">
|
||||
{% if include_nav or include_search or include_next_prev or repo_url %}
|
||||
<!-- Expander button -->
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
@@ -10,6 +11,7 @@
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
<!-- Main title -->
|
||||
<a class="navbar-brand" href="{{ homepage_url }}">{{ site_name }}</a>
|
||||
@@ -17,28 +19,31 @@
|
||||
|
||||
<!-- Expanded navigation -->
|
||||
<div class="navbar-collapse collapse">
|
||||
<!-- Main navigation -->
|
||||
<ul class="nav navbar-nav">
|
||||
{% for nav_item in nav %}
|
||||
{% if nav_item.children %}
|
||||
<li class="dropdown{% if nav_item.active %} active{% endif %}">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ nav_item.title }} <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
{% for nav_item in nav_item.children %}
|
||||
<li {% if nav_item.active %}class="active"{% endif %}>
|
||||
<a href="{{ nav_item.url }}">{{ nav_item.title }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
<li {% if nav_item.active %}class="active"{% endif %}>
|
||||
<a href="{{ nav_item.url }}">{{ nav_item.title }}</a>
|
||||
</li>
|
||||
{% if include_nav %}
|
||||
<!-- Main navigation -->
|
||||
<ul class="nav navbar-nav">
|
||||
{% for nav_item in nav %}
|
||||
{% if nav_item.children %}
|
||||
<li class="dropdown{% if nav_item.active %} active{% endif %}">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ nav_item.title }} <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
{% for nav_item in nav_item.children %}
|
||||
<li {% if nav_item.active %}class="active"{% endif %}>
|
||||
<a href="{{ nav_item.url }}">{{ nav_item.title }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
<li {% if nav_item.active %}class="active"{% endif %}>
|
||||
<a href="{{ nav_item.url }}">{{ nav_item.title }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% if include_search or include_next_prev or repo_url %}
|
||||
<!-- Search, Navigation and Repo links -->
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% if include_search %}
|
||||
@@ -46,6 +51,7 @@
|
||||
<a href="#searchModal" data-toggle="modal"><i class="fa fa-search"></i> Search</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if include_next_prev %}
|
||||
<li {% if not previous_page %}class="disabled"{% endif %}>
|
||||
<a rel="next" {% if previous_page %}href="{{ previous_page.url }}"{% endif %}>
|
||||
<i class="fa fa-arrow-left"></i> Previous
|
||||
@@ -56,6 +62,7 @@
|
||||
Next <i class="fa fa-arrow-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if repo_url %}
|
||||
<li>
|
||||
<a href="{{ repo_url }}">
|
||||
@@ -69,6 +76,7 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user