Skip to content

Commit

Permalink
from master
Browse files Browse the repository at this point in the history
  • Loading branch information
Robpol86 committed Aug 22, 2016
1 parent c4b1c10 commit 63a69e9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Unreleased
Added
* Option to enable warning banner in old/development versions. Similar to Jinja2's documentation.
* Command line options: ``--banner-greatest-tag`` ``--banner-recent-tag`` ``--show-banner`` ``--banner-main-ref``
* Jinja2 context functions: ``vhasdoc()`` ``vpathto``
* Jinja2 context functions: ``vhasdoc()`` ``vpathto()``
* Jinja2 context variables: ``scv_show_banner`` ``scv_banner_greatest_tag`` ``scv_banner_main_ref_is_branch``
``scv_banner_main_ref_is_tag`` ``scv_banner_main_version`` ``scv_banner_recent_tag``

Expand Down
33 changes: 33 additions & 0 deletions docs/context.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,36 @@ branches or just tags.
{%- endfor %}
</dl>
Functions
=========

.. function:: vhasdoc(other_version)

Similar to Sphinx's `hasdoc() <sphinx_hasdoc_>`_ function. Returns True if the current document exists in another
version.

.. code-block:: jinja
{% if vhasdoc('master') %}
This doc is available in <a href="../master/index.html">master</a>.
{% endif %}
.. function:: vpathto(other_version)

Similar to Sphinx's `pathto() <sphinx_pathto_>`_ function. Has two behaviors:

1. If the current document exists in the specified other version pathto() returns the relative URL to that document.
2. If the current document does not exist in the other version the relative URL to that version's
`master_doc <sphinx_master_doc_>`_ is returned instead.

.. code-block:: jinja
{% if vhasdoc('master') %}
This doc is available in <a href="{{ vpathto('master') }}">master</a>.
{% else %}
Go to <a href="{{ vpathto('master') }}">master</a> for the latest docs.
{% endif %}
Other Variables
===============

Expand Down Expand Up @@ -101,3 +131,6 @@ Other Variables

.. _Jinja2: http://jinja.pocoo.org/
.. _sphinx_context: http://www.sphinx-doc.org/en/stable/config.html?highlight=context#confval-html_context
.. _sphinx_hasdoc: http://www.sphinx-doc.org/en/stable/templating.html#hasdoc
.. _sphinx_master_doc: http://www.sphinx-doc.org/en/stable/config.html#confval-master_doc
.. _sphinx_pathto: http://www.sphinx-doc.org/en/stable/templating.html#pathto

0 comments on commit 63a69e9

Please sign in to comment.