Skip to main content

Introduction

Currently, June 7, 2015, Sphinx 1.3.1 sorts indices only with ‘Normalization Form Canonical Decomposition(NFD)’. And what is worse, grouping is done only with US-ASCII. There is non or few problems when you use the language similar to English, because the NFD method decompose diacritical marks.

But with the other languages, the grouping is useless. Almost all characters are grouped into ‘Symbols’. What a meaningless behavior it is!

I don’t know what happens with each language in the world, but one of the worst might be Japanese case. The many terms are written with kanzi (kanji, 漢字, Chinese characters), and the sorting should be done by how to read, that generally cannot be defined from the characters of the terms.

This extension tries to resolve these problems above, using sortorder. Not only with these problematic languages, you can define the alternate sort order for any language you want.

Sorry to say, this extension can resolve .. glossary:: directive only, by replacing with .. gosyu:: one. Other directives like index would be resolved with future release.

License

2-clause BSD, same as the Sphinx project.

Installation

You can install or uninstall this package like another Python packages. Also, you can use this package without installing this package on your Python systems, the configuration file of Sphinx(conf.py) enable you to use.

System requirements

Tested with 32bit version of Python 2.7.10 and 64bit version of 3.4.3, both on the Microsoft Windows 8.1 Pro 64bit edition. But with another versions and on another OSs would be usable.

Python 3 is required if you need full unicode support. When used with Python 2, the usable character set is limited with local encoding.

How to install

You can install this package as you will do with another one.

  1. Open a console and do pip install gosyu.

    On the MS-Windows, <python_installed_path>\Scripts\pip.exe install gosyu.

  2. Or when you get zip archive like gosyu-2.0.6(.zip) where ‘2.0.6’ is version number, change current directiory to the folder that has the zip file, and do pip install gosyu-2.0.6.zip.

    On the MS-Windows, <python_installed_path>\Scripts\pip.exe install gosyu-2.0.6.zip.

  3. Or, this way is the Sphinx specific, you can use this package just extracted any folder you want. the conf.py enables you to use the themes and extensions.

If you don’t resolve dependencies, you also have to get sortorder module.

How to use

1) Add the paths

As another extensions, you can use this extension by editing conf.py.

First, you should add:

# add 4 lines below
import distutils.sysconfig
site_package_path = distutils.sysconfig.get_python_lib()
sys.path.insert(0, os.path.join(site_package_path, 'sortorder'))
sys.path.insert(0, os.path.join(site_package_path, 'sphinxcontrib/gosyu'))

Or, when you don’t install with pip or like,

# add just 2 line below
sys.path.insert(0, '<path_to_the_folder_contains_sortorder___init___py>')
sys.path.insert(0, '<path_to_the_folder_contains_gosyu_py>')

If you want to use your own sort order module(.py file), you should add the path of it, too:

# after adding paths as above, add the line below.
sys.path.insert(0, '<path_to_the_folder_sort_order_xx_py>')

2) declare the extensions

Next, add gosyu extension into extension list:

language = 'xx' # make sure your language if you want to use autodetect

#
# (snip...)
#

extension = [
  'sort_order_xx', # omit when using one of preset sort order or autodetect
  'sortorder', # you can omit always, because 'gosyu' automatically loads
  'gosyu', # required.
] # Of course you can add another extensions.

3) replace ‘glossary’ with ‘gosyu’

Now, just replace .. glossary:: with .. gosyu::. When :sorted: is given, the terms are sorted in each glossary.

And anyway, the general index in genindex.html is also sorted as you want to define.

4) add the how to read each terms

For the languages like Japanese, .. gosyu:: directive has another option :yomimark: <a separater char>. the separator is a character you want to use split. When the separator is given, the term can be followed the string how to read. If you think some terms don’t need the reading, you can simply omit for the terms.

Consider to use the preset Japanese sort order defined in sortorder extension:

language = 'ja'

#
# (snip...)
#

extension = [
  'gosyu',
]  # all omitted modules will be automatically loaded

And write glossary like:

.. gosyu::
  :sorted:
  :yomimark: 、

  ひらがな

    比較的曲線が多い日本語の表音文字

  カタカナ

    比較的直線が多い日本語の表音文字

  漢字、かんじ

    日本語でも使われる表意文字

  英字、えいじ

    義務教育で教わるため、日本語でもよく使われる表音文字

  記号、きごう

    国内国外を問わず多種多様な記号が携帯電話などでも使えるようになってきた

The separator is 、 (U+3001) in this case.

This reorders the terms 英字 -> カタカナ -> 漢字 -> 記号 -> ひらがな. The preset sortorder.ja module sorts them depending on えいじ, カタカナ, かんじ, きごう, ひらがな.

And in the genindex.html, カタカナ, 漢字, 記号 is grouped in one heading か. Also because the module desides it depending on how to read.

5) options written in conf.py

There is 3 options to change some strings.

  • gosyu_shortname = u'用語集'

    • a short name for the index, for use in the relation bar in

  • gosyu_localname = u'用語集'

    • the section title for the index

  • gosyu_anchor_prefix = 'yogo_'

    • the prefix of the anchors to link from/to HTML files.

TODO

I don’t know how to make the reference to std-gosyu.html like :ref:`genindex` .

As workaround, use:

`gosyu index <./std-gosyu.html>`_

or:

gosyu_index_

...

.. _gosyu_index: ./std-gosyu.html

Author

Suzumizaki-Kimitaka(鈴見咲 君高), 2011-2015

History

2.0.6(2015-07-04):

Fix documentation(this file) for PyPI.

2.0.5(2015-07-04):

2013-12-07:

Add Python 3 support.

2013-12-06:

updated to meet Sphinx 1.2.

2011-05-24:

First release. Includes sortorder and unicode_ids.

Metadata

Release files for gosyu 2.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gosyu 2.0.6
File Size Uploaded Provenance
gosyu-2.0.6.zip 297.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for gosyu 2.0.6
File Interpreter ABI Platform
gosyu-2.0.6-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 552.8 kB

Release files / gosyu-2.0.6.zip

Download URL gosyu-2.0.6.zip
Size 297.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b6055b192c91f9a68e3b398f5e2a80a749309ba7906ed7203149551a3ad82399
BLAKE2b-256 checksum
How to use checksums
e9c4c0d5e3e5e0a1701ce53f619a198410c527bff99a08b91dc1ce56fad0d11a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / gosyu-2.0.6-py2.py3-none-any.whl

Download URL gosyu-2.0.6-py2.py3-none-any.whl
Size 255.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
306b3e41fd9e2ff765488e08eb68e6bb258fe59b7c25498cfe941a7ff4c66b12
BLAKE2b-256 checksum
How to use checksums
ed5b3ba1c68313de51d425ecde239d1a782032d591758a231e860efcfd3eced7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for gosyu 2.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

2.0.6 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page