Metadata-Version: 2.1
Name: sphinxcontrib.kana-text
Version: 0.17.5
Summary: KanaText class extends the functionality of Text class.
Home-page: https://qiita.com/tags/sphinxcotrib.kana_text
Author: @koKekkoh
Maintainer: KaKkou
License: BSD
Keywords: sphinx,sphinxcontrib,japanese,ja,kana_text,glossary,index,kana
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Sphinx :: Extension
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: Japanese
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Documentation :: Sphinx
Classifier: Topic :: Utilities
Description-Content-Type: text/x-rst
License-File: LICENSE

extends the functionality of the Text class. any person, who use index/glossary directives with Japanse Kanji, is to be so happy.

conf.py
-------

First of all, add **sphinxcontrib-kana_text** to sphinx extension list in conf.py

.. code-block:: python

   extensions = ['sphinxcontrib.kana_text']

.. code-block:: python

   #html_kana_text_on_genindex = False
   #html_kana_text_use_own_indexer = 'large'

.. warning::

   You need 'genindex.html' for taking True on html_kana_text_on_genindex.

rst file
--------

then use **index** directive, **glossary** directive, **index** role and **kana** role.

You can specify the follwings:

.. code-block:: rst

   .. index:: ようご|用語^21

.. code-block:: rst

   .. glossary::

      ようごいち|用語壱^212
        用語１の説明。

And you can also use index/kana role. 

build
-----

finally, build your sphinx project:

.. code-block:: sh

   $ make kana

take a look at genindex.html.

genindex.html
-------------
.. code-block:: jinja

   {# genindex.html #}
   {%- extends "layout.html" %}
   {% set title = _('Index') %}

   {% macro kana_entry(kname) %}
     {%- if kname is string -%}
     {{ kname|e }}
     {%- else %}
     {%- for isruby, val in kname -%}
       {%- if isruby -%}
       <ruby><rb>{{ val[0]|e }}</rb><rp>（</rp>
       <rt>{{ val[1]|e }}</rt><rp>）<rp>
       </ruby>
       {%- else %}
       {{ val|e }}
       {%- endif %}
     {%- endfor %}
     {%- endif %}
   {% endmacro %}

   {% macro indexentries(firstname, links) %}
     {%- if links -%}
       <a href="{{ links[0][1] }}">
       {%- if links[0][0] %}<strong>{% endif -%}
       {{ kana_entry(firstname) }}
       {%- if links[0][0] %}</strong>{% endif -%}
       </a>

       {%- for ismain, link in links[1:] -%}
         , <a href="{{ link }}">{% if ismain %}<strong>{% endif -%}
         [{{ loop.index }}]
         {%- if ismain %}</strong>{% endif -%}
         </a>
       {%- endfor %}
     {%- else %}
       {{ kana_entry(firstname) }}
     {%- endif %}
   {% endmacro %}

   {% block body %}

   <h1 id="index">{{ _('Index') }}</h1>

   <div class="genindex-jumpbox">
    {% for key, dummy in genindexentries -%}
    <a href="#{{ key }}"><strong>{{ key }}</strong></a>
    {% if not loop.last %}| {% endif %}
    {%- endfor %}
   </div>

   {%- for key, entries in genindexentries %}
   <h2 id="{{ key }}">{{ key }}</h2>
   <table style="width: 100%" class="indextable genindextable"><tr>
     {%- for column in entries|slice_index(2) if column %}
     <td style="width: 33%; vertical-align: top;"><ul>
       {%- for entryname, (links, subitems, _) in column %}
         <li>{{ indexentries(entryname, links) }}
         {%- if subitems %}
         <ul>
         {%- for subentryname, subentrylinks in subitems %}
           <li>{{ indexentries(subentryname, subentrylinks) }}</li>
         {%- endfor %}
         </ul>
         {%- endif -%}</li>
       {%- endfor %}
     </ul></td>
     {%- endfor %}
   </tr></table>
   {% endfor %}

   {% endblock %}

   {% block sidebarrel %}
   {% if split_index %}
      <h4>{{ _('Index') }}</h4>
      <p>{% for key, dummy in genindexentries -%}
      <a href="{{ pathto('genindex-' + key) }}"><strong>{{ key }}</strong></a>
        {% if not loop.last %}| {% endif %}
      {%- endfor %}</p>

      <p><a href="{{ pathto('genindex-all') }}"><strong>{{ _('Full index on one page') }}</strong></a></p>
   {% endif %}
      {{ super() }}
   {% endblock %}



