Generally, you don’t have to know read here. Please read gosyu extension.

通常はこの頁を読む必要はありません。使い方などについてはgosyu拡張(日本語版説明書)をご覧ください。

Module gosyu

The Sphinx extension to provide yomigana to glossary.

copyright:© 2011-2015 by Suzumizaki-Kimitaka(only for additional works)
license:2-clause BSD.

This is the extension for Sphinx to add the gosyu directive used to replace glossary.

The gosyu directive can sort the terms by the order given from the user(document writer). Especially to support the language like Japanese, :yomimark: option is exist and make the way adding the reading(shows how to read) to each term.

This module depends on the module sortorder. The document of the module shows how to make your own order for the languages you want.

yomimark can be one of single_char_or_whitespace_or_unicode. the acceptable words are defined in docutils.parsers.rst.directives as follows:

The every term is splited by yomimark. 1st is the term itself, 2nd is treated as Yomigana(how to read). Currently 3rd and followers are simply ignored, but using this way, the ‘mono ruby’ may be supported for the future. (see HTML ruby module for example.)

Not all the entry have to give yomigana. When yomigana is not assigned, the name of the entry is used to sort.

yomigana itself is currently not shown in output HTML files. They’re only used to sort.

class gosyu.GosyuDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Yomigana featured version of sphinx.domains.std.Glossary

The option yomimark is added.

domainname = None

can be ‘’ which need to be distinguished with None.

run()

Inherit ObjectDescription.run, called by docutils

Base codes are copied from sphinx.domains.std.Glossary.

class gosyu.GosyuIndex(*args, **kwargs)

Index representation class supports yomigana(how to read)

Pick the terms declared with GosyuDirective (.. gosyu::) and make the std-gosyu.html.

Support 2 options, gosyu_shortname and gosyu_localname given in conf.py.

localname = 'gosyu_dummy'

overwritten by __init__()

shortname = 'gosyu_dummy'

overwritten by __init__()

gosyu.determine_sort_order(app)

Determine sort order used in this module

Parameters:cfg (sphinx.config.Config) – you can give from Sphinx with app.config, builder.config etc.
Return type:None
Returns:None
gosyu.make_term_from_paragraph_node(termnodes, ids)

Copied function of sphinx.domains.std.term_from_paragraph_node()

Currently, no lines are modified. Called from GosyuDirective.run().

gosyu.make_termnodes_from_paragraph_node(env, domain_obj, node, yomi)

helper function of GosyuDirective.run()

Parameters:
  • env (Sphinx.BuildEnvironment) – current build environment
  • domain_obj (dict) – reference to the dict of the termtext and corresponding informations(docname, id_used_for_anchor, yomigana)
  • node (docutils.nodes.paragraph) – the node represents the term
  • yomi (str_or_unicode) – the string shows how to read or the term itself
Return type:

list

Returns:

the list of docutils.Node

Copied from sphinx.domains.std and modified. Called from GosyuDirective.run().

gosyu.setup(app)

Extend the Sphinx as we want, called from the Sphinx

Parameters:app (sphinx.application.Sphinx) – the object to add builder or something.