Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown directive type "glossary" #15

Open
Hoteryoung opened this issue Jun 4, 2021 · 1 comment
Open

Unknown directive type "glossary" #15

Hoteryoung opened this issue Jun 4, 2021 · 1 comment

Comments

@Hoteryoung
Copy link

Hoteryoung commented Jun 4, 2021

Sphinx supports the directive type "glossary":
https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-glossary

But rstfmt reports a traceback about it:

$ rstfmt rstfmt_issue_glossary.rst                                                                                                  3.8.3
:5: (ERROR/3) Unknown directive type "glossary".

.. glossary::

   term_a
      This is term a.

   term_b
      This is term b.


Traceback (most recent call last):
  File "/Users/yanghaote/.pyenv/versions/3.8.3/bin/rstfmt", line 10, in <module>
    sys.exit(main())
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/rstfmt/__main__.py", line 46, in main
    doc = rstfmt.parse_string(inp)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 750, in parse_string
    parser.parse(s, doc)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/__init__.py", line 191, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 170, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/statemachine.py", line 241, in run
    context, next_state, result = self.check_line(
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 3005, in text
    self.section(title.lstrip(), source, style, lineno + 1, messages)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 393, in new_subsection
    newabsoffset = self.nested_parse(
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/statemachine.py", line 241, in run
    context, next_state, result = self.check_line(
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2342, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2099, in directive
    return self.unknown_directive(type_name)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2280, in unknown_directive
    error = self.reporter.error(
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/utils/__init__.py", line 231, in error
    return self.system_message(self.ERROR_LEVEL, *args, **kwargs)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 274, in system_message
    msg = super().system_message(level, message, *children, **kwargs)
  File "/Users/yanghaote/.pyenv/versions/3.8.3/Python.framework/Versions/3.8/lib/python3.8/site-packages/docutils/utils/__init__.py", line 197, in system_message
    raise SystemMessage(msg, level)
docutils.utils.SystemMessage: :5: (ERROR/3) Unknown directive type "glossary".

.. glossary::

   term_a
      This is term a.

   term_b
      This is term b.

The rstfmt_issue_glossary.rst file looks like:

######
 Test
######

.. glossary::

   term_a
      This is term a.

   term_b
      This is term b.


This is a cross-reference example for :term:`term_a`.
3-w-c added a commit to 3-w-c/rstfmt that referenced this issue Jan 14, 2022
@dzhu
Copy link
Owner

dzhu commented Jul 18, 2022

The latest 0.0.11 release partially fixes this; formatting will work as long as the body uses standard definition list syntax rather than the extended version supported by glossary (which allows multiple terms for one definition and inline markup in terms). See the relevant commit for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants