Giter VIP home page Giter VIP logo

rstfmt's People

Contributors

0mp avatar dzhu avatar jackenmen avatar pathai-epol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rstfmt's Issues

Sphinx requirement seems wrong

Hello,

seems sphinx has become incompatible:

    rst_extras.register()
  File "/usr/local/lib/python3.9/site-packages/rstfmt/rst_extras.py", line 145, in register
    _add_directive("literalinclude", sphinx.directives.code.LiteralInclude)
  File "/usr/local/lib/python3.9/site-packages/sphinx/deprecation.py", line 48, in __getattr__
    return getattr(self._module, name)
AttributeError: module 'sphinx.directives' has no attribute 'code'

Downgrading sphinx to 2.4 solves this.

add a `pre-commit` hook

Would be great to get this tool as a pre-commit hook. For now I've done this:

  - repo: local
    hooks:
      - id: rst-fmt
        name: rst-fmt
        language: python
        entry: rstfmt
        additional_dependencies: [ rstfmt ]
        types: [ rst ]

docutils<0.18 pin makes rstfmt incompatible with most distros

6025bd2 added this pin, and when I try with docutils 0.19 I encounter the following which is probably the problem

[   77s] + python3.8 -m rstfmt --check README.rst sample.rst
[   79s] Traceback (most recent call last):
[   79s]   File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
[   79s]     return _run_code(code, main_globals, None,
[   79s]   File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
[   79s]     exec(code, run_globals)
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/__main__.py", line 104, in <module>
[   79s]     main()
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/__main__.py", line 95, in main
[   79s]     do_file(args, path, misformatted)
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/__main__.py", line 44, in do_file
[   79s]     output = rstfmt.format_node(args.width, doc)
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/rstfmt.py", line 734, in format_node
[   79s]     ret = "\n".join(fmt(node, FormatContext(0, width, "", "", [], 0)))
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/rstfmt.py", line 481, in document
[   79s]     yield from chain_intersperse("", fmt_children(node, ctx))
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/rstfmt.py", line 75, in chain_intersperse
[   79s]     yield from x
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/rstfmt.py", line 477, in section
[   79s]     yield from chain_intersperse("", fmt_children(node, ctx.in_section()))
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/rstfmt.py", line 75, in chain_intersperse
[   79s]     yield from x
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/rstfmt.py", line 437, in paragraph
[   79s]     yield from wrap_text(ctx.width, chain(fmt_children(node, ctx)))
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/rstfmt.py", line 166, in wrap_text
[   79s]     items = list(items)
[   79s]   File "/home/abuild/rpmbuild/BUILD/rstfmt-0.0.11/rstfmt/rstfmt.py", line 588, in Text
[   79s]     yield node.rawsource.replace(r"\ ", "")
[   79s] AttributeError: 'Text' object has no attribute 'rawsource'

Most recent distros are using 0.19 ; c.f. https://repology.org/project/python:docutils/versions

Inconsistent list formatting

Hello,

it seems that if a list contains items which are broken to 3 lines, there is spaces in between them:

Below is an example. I would love to be able to enforce this, because it is rather random, and in my changelog, it looks inconsistent because I have these sections with list items, and some look cramped and others nice and with space.

I don't know if it's acceptable for you to make this configurable? So far only width is configurable, and I take that you may like black not want to go there. What's your take?

****************
 Organisational
****************

-  Enhanced Github issue raising instructions.
-  Apply ``rstfmt`` to all documentation and make it part of the commit
   hook.
-  Make sure to check Scons files as well. This would have caught the
   code used to disable ``clcache`` temporarily.
-  Do not mention Travis in PR template anymore, we have stopped using
   it.
-  Updated requirements to latest versions.
-  Bump requirements for development to 3.7 at least, toosl like black
   do not work with 3.6 anymore.
-  Started work on Nuitka Python, a CPython fork intended for enhanced
   performance and standalone support with Nuitka.

**********
 Cleanups
**********

-  Determine system prefix without virtualenv outside of Scons, such
   that plugins can share the code. There was duplication with the
   ``numpy`` plugin, and this will only be more complete using all
   approaches. This also removes a lot of noise from the scons file
   moving it to shared code.

-  The Qt plugins now collect QML files with cleaner code.

Unknown node type figure!

reStructuredText supports directive figure:
https://docutils.sourceforge.io/docs/ref/rst/directives.html#figure

But rstfmt reports a traceback about it:

$ rstfmt index.rst
Traceback (most recent call last):
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 730, in fmt
    func = getattr(Formatters, type(node).__name__)
AttributeError: type object 'Formatters' has no attribute 'figure'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/linji/.pyenv/versions/3.8.2/bin/rstfmt", line 8, in <module>
    sys.exit(main())
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/main.py", line 53, in main
    output = rstfmt.format_node(args.width, doc)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 739, in format_node
    return "\n".join(fmt(node, FormatContext(0, width, "", "", [], 0))) + "\n"
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 482, in document
    yield from chain_intersperse("", fmt_children(node, ctx))
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 75, in chain_intersperse
    yield from x
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 478, in section
    yield from chain_intersperse("", fmt_children(node, ctx.in_section()))
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 71, in chain_intersperse
    for x in it:
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 209, in <genexpr>
    return (fmt(c, ctx) for c in node.children)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 732, in fmt
    raise ValueError(f"Unknown node type {type(node).__name__}!")
ValueError: Unknown node type figure!

Here is the index.rst:

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

.. figure:: ./000000.png
   :scale: 50 %
   :align: center

   caption

Tolerate Sphinx extensions

First off, rstfmt looks great and we'd like to use it in our project! CC @sk1p

In a first test, handling the formatting for Sphinx extensions like https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html was a stumbling point.

How to reproduce

Format a document that uses the Sphinx doctest extension:

Reproducer
==========

.. testsetup:: *

    import numpy as np

What happens

(libertem) C:\Users\dwebe\Documents\src\LiberTEM>rstfmt prototypes\reproducers\rstfmt.rst
:4: (ERROR/3) Unknown directive type "testsetup".

.. testsetup:: *

    import numpy as np
Traceback (most recent call last):
  File "c:\users\dwebe\.conda\envs\libertem\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\dwebe\.conda\envs\libertem\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\dwebe\.conda\envs\libertem\Scripts\rstfmt.exe\__main__.py", line 7, in <module>
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\rstfmt\__main__.py", line 46, in main
    doc = rstfmt.parse_string(inp)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\rstfmt\rstfmt.py", line 750, in parse_string
    parser.parse(s, doc)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\__init__.py", line 191, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\states.py", line 170, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\statemachine.py", line 241, in run
    context, next_state, result = self.check_line(
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\states.py", line 2769, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\states.py", line 393, in new_subsection
    newabsoffset = self.nested_parse(
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\states.py", line 281, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\statemachine.py", line 241, in run
    context, next_state, result = self.check_line(
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\states.py", line 2342, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\states.py", line 2099, in directive
    return self.unknown_directive(type_name)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\parsers\rst\states.py", line 2280, in unknown_directive
    error = self.reporter.error(
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\utils\__init__.py", line 231, in error
    return self.system_message(self.ERROR_LEVEL, *args, **kwargs)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\rstfmt\rstfmt.py", line 274, in system_message
    msg = super().system_message(level, message, *children, **kwargs)
  File "c:\users\dwebe\.conda\envs\libertem\lib\site-packages\docutils\utils\__init__.py", line 197, in system_message
    raise SystemMessage(msg, level)
docutils.utils.SystemMessage: :4: (ERROR/3) Unknown directive type "testsetup".

.. testsetup:: *

    import numpy as np

What should happen

Blocks with unknown directives are ignored. Possibly, they can trigger a warning. Possibly, there could be an interface to write formatters for new directives that could be installed as part of an extension that implements them in Sphinx.

Table formatting breaks

Trying to format

==== =====
Head Foot
==== =====
1    1234
12   12 34
123  123 4
1234 123
==== =====

results in

+----+-----+
| Head | Foot |
+====+=====+
| 1  | 1234 |
+----+-----+
| 12 | 12  |
|    | 34  |
+----+-----+
| 123 | 123 |
|    | 4   |
+----+-----+
| 1234 | 123 |
+----+-----+

which is a broken table.

The problem seems to happen when the cell content is a single word and fills the full width of the cell or full_width-1.

`Unknown interpreted text role "guilabel".` error when using `guilabel`

Using the following code syntax :

Boot switches position for :guilabel:`USB Mass Storage` boot source`

And running rstfmt on my source folder using rstfmt source, I'm having the following error :

:25: (ERROR/3) Unknown interpreted text role "guilabel".
Traceback (most recent call last):
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 305, in next_line
    self.line = self.input_lines[self.line_offset]
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 1148, in __getitem__
    return self.data[i]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 233, in run
    self.next_line()
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 308, in next_line
    raise EOFError
EOFError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workspaces/comboard-linux-image/docs/.venv/bin/rstfmt", line 8, in <module>
    sys.exit(main())
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/__main__.py", line 97, in main
    do_file(args, f, misformatted)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/__main__.py", line 31, in do_file
    doc = rstfmt.parse_string(inp)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 758, in parse_string
    parser.parse(s, doc)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/__init__.py", line 183, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 170, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 240, in run
    context, next_state, result = self.check_line(
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 452, in check_line
    return method(match, context, next_state)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2779, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 393, in new_subsection
    newabsoffset = self.nested_parse(
  File "/workspaces/comboard-linux-image/docs/.venv/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 "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 240, in run
    context, next_state, result = self.check_line(
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 452, in check_line
    return method(match, context, next_state)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 1320, in enumerator
    newline_offset, blank_finish = self.nested_list_parse(
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 318, in nested_list_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 240, in run
    context, next_state, result = self.check_line(
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 452, in check_line
    return method(match, context, next_state)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2564, in enumerator
    listitem, blank_finish = self.list_item(match.end())
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 1294, in list_item
    self.nested_parse(indented, input_offset=line_offset,
  File "/workspaces/comboard-linux-image/docs/.venv/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 "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/statemachine.py", line 246, in run
    result = state.eof(context)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2722, in eof
    self.blank(None, context, None)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2713, in blank
    paragraph, literalnext = self.paragraph(
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 418, in paragraph
    textnodes, messages = self.inline_text(text, lineno)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 427, in inline_text
    nodes, messages = self.inliner.parse(text, lineno,
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 649, in parse
    before, inlines, remaining, sysmessages = method(self, match,
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 792, in interpreted_or_phrase_ref
    nodelist, messages = self.interpreted(rawsource, escaped, role,
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 892, in interpreted
    msg = self.reporter.error(
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/utils/__init__.py", line 231, in error
    return self.system_message(self.ERROR_LEVEL, *args, **kwargs)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 281, in system_message
    msg = super().system_message(level, message, *children, **kwargs)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/docutils/utils/__init__.py", line 197, in system_message
    raise SystemMessage(msg, level)
docutils.utils.SystemMessage: :25: (ERROR/3) Unknown interpreted text role "guilabel".

  • rstfmt version : rstfmt 0.0.13
  • python3 version : Python 3.8.10

Unknown directive type "literalinclude"

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

But if the rst file includes the directive "literalinclude", rstfmt will report a traceback:

$ rstfmt index.rst
:5: (ERROR/3) Unknown directive type "literalinclude".

.. literalinclude:: test.txt
Traceback (most recent call last):
  File "/Users/linji/.pyenv/versions/3.8.2/bin/rstfmt", line 8, in <module>
    sys.exit(main())
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/main.py", line 40, in main
    doc = rstfmt.parse_string(inp)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 706, in parse_string
    parser.parse(s, doc)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/parsers/rst/__init__.py", line 191, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 170, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/statemachine.py", line 241, in run
    context, next_state, result = self.check_line(
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/linji/.pyenv/versions/3.8.2/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/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 393, in new_subsection
    newabsoffset = self.nested_parse(
  File "/Users/linji/.pyenv/versions/3.8.2/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/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/statemachine.py", line 241, in run
    context, next_state, result = self.check_line(
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2342, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construc
t
    return method(self, expmatch)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2099, in directive
    return self.unknown_directive(type_name)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/parsers/rst/states.py", line 2280, in unknown_directive
    error = self.reporter.error(
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/docutils/utils/__init__.py", line 231, in error
    return self.system_message(self.ERROR_LEVEL, *args, **kwargs)
  File "/Users/linji/.pyenv/versions/3.8.2/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 274, in system_message
    msg = super().system_message(level, message, *children, **kwargs)
  File "/Users/linji/.pyenv/versions/3.8.2/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 "literalinclude".

.. literalinclude:: test.txt

The index.rst file looks like:

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

.. literalinclude:: test.txt

License/Thank you?

Hey @dzhu , I wanna say thank you, for your project. Without this I wouldn’t be able to do a couple of things, I created a repository based about on this, it’s a GitHub action that just automates formatting RST files. I was just wondering if there is a way to cite this, or change my license, or I’m not sure. I want to give you credit, heavily!

Here is my repository.

Please let me know what actions I should take so I can do this properly!

Ignore a file or subsection within file.

First off, thanks for this highly useful tool!

Is it possible to ignore a file or add inline directives to ignore sections?

Here is some example content I have in a file:

   <script>
     $(document).ready(function() {
       $('.cs').parent().parent().addClass('coming-soon');
       $('.no').parent().parent().addClass('not-supported');
       $('.yes').parent().parent().addClass('supported');
     });
   </script>
   <style>
      .not-supported {background-color:#f2ada0;}
      .supported {background-color:#f2f8f0;}
      .coming-soon {background-color:#f1faff;}
   </style>

+----------------------------------------+-------------------+-----------------------+
| xxxxxxxx xxxx                          | xxxxxx xxxxxxx    | xxxxxx xxxxxxx        |
+========================================+===================+=======================+
| XXX                                    | :yes:`Yes`        | :yes:`Yes`            |
+----------------------------------------+-------------------+-----------------------+

When running rstfmt I get the following error: docutils.utils.SystemMessage: :46: (ERROR/3) Unknown interpreted text role "yes".
I know I am doing some weird stuff here. So ideally I'd be able to ignore this file when running rstfmt on a directory. Or add inline directives like .. rstfmt-ignore-start xyz .. rstfmt-ignore-end

Support a `--diff` like option

👋 Great tool! Something I feel like that is missing is the ability for me to see the changes the tool would make (without actually editing the file in place).

Breaking block quotes

Working on my Changelog.rst for Nuitka, I discovered this breaking change done by rstfmt 0.0.6:

From this code:

python 2.6::

   Pystone(1.1) time for 50000 passes = 0.48
   This machine benchmarks at 104167 pystones/second

it creates:

python 2.6:

.. code::

   Pystone(1.1) time for 50000 passes = 0.48
   This machine benchmarks at 104167 pystones/second

The later is wrong, this is not code (I think Python is the default). When I run it again, it does not complain about invalid Python, but if I add it, it does. The rst2pdf however complains very loudly about this rest code for that reason. So I think, this reveals 2 bugs in rst2fmt, fist missing default language, second turning block quotes to code, which is not correct. I am merely quoting program outputs with block quotes.

On a side note, I was deeply impressed by the black integration you are using there, very nice, and it found a bunch of syntax errors in my code snippets, good job there, making that happen, very appreciated. For now, I will do a search and replace to fix these up, but I can use the end result otherwise I believe.

`Unknown node type option_list` error when using definitions starting with hypen `-`

Using the following code syntax :

This scripts requires two arguments :

-d
    The disk where to create the image (e.g: ``sda``)

-i
    The image name (e.g: ``iecharge-image-comboard.wic``)

And running rstfmt on my source folder using rstfmt source, I'm having the following error :

Traceback (most recent call last):
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 733, in fmt
    func = getattr(Formatters, type(node).__name__)
AttributeError: type object 'Formatters' has no attribute 'option_list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workspaces/comboard-linux-image/docs/.venv/bin/rstfmt", line 8, in <module>
    sys.exit(main())
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/__main__.py", line 97, in main
    do_file(args, f, misformatted)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/__main__.py", line 44, in do_file
    output = rstfmt.format_node(args.width, doc)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 742, in format_node
    ret = "\n".join(fmt(node, FormatContext(0, width, "", "", [], 0)))
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 488, in document
    yield from chain_intersperse("", fmt_children(node, ctx))
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 75, in chain_intersperse
    yield from x
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 484, in section
    yield from chain_intersperse("", fmt_children(node, ctx.in_section()))
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 75, in chain_intersperse
    yield from x
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 484, in section
    yield from chain_intersperse("", fmt_children(node, ctx.in_section()))
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 71, in chain_intersperse
    for x in it:
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 209, in <genexpr>
    return (fmt(c, ctx) for c in node.children)
  File "/workspaces/comboard-linux-image/docs/.venv/lib/python3.8/site-packages/rstfmt/rstfmt.py", line 735, in fmt
    raise ValueError(f"Unknown node type {type(node).__name__}!")
ValueError: Unknown node type option_list!

Putting -d and -i in between ticks solves the issue :

``-d``
   The disk where to create the image (e.g: ``sda``)

``-i``
   The image name (e.g: ``iecharge-image-comboard.wic``)

  • rstfmt version : rstfmt 0.0.13
  • python3 version : Python 3.8.10

Unknown directive type "glossary"

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`.

Broken due to Sphinx 4.0 release

It looks like Sphinx 4.0 was released May 9, 2020, which broke rstfmt.

$ rstfmt
Traceback (most recent call last):
  File "/usr/local/bin/rstfmt", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/rstfmt/__main__.py", line 36, in main
    rst_extras.register()
  File "/usr/local/lib/python3.9/site-packages/rstfmt/rst_extras.py", line 145, in register
    _add_directive("literalinclude", sphinx.directives.code.LiteralInclude)
  File "/usr/local/lib/python3.9/site-packages/sphinx/deprecation.py", line 52, in __getattr__
    return getattr(self._module, name)
AttributeError: module 'sphinx.directives' has no attribute 'code'

I did some initial triage, but I don't see the problem, the code.py file is still there. 🤷

I recommend adding something like sphinx>=2.4.0, <4.0 to your install_requires in setup.py. Or when you fix it, sphinx>=2.4.0, <5.0. 🙂

rstfmt updates timestamps of unchanged files

Build systems like make and many other tools, including sphinx, use file timestamps to determine if sources were changed and targets need to be rebuilt. Currently, rstfmt updates the timestamps of files that were not changed, thus causing a full rebuild in a subsequent run of the build tool. It would be great to change this behaviour so that only real file changes cause an update to the timestamp.

Run on multiple files

Is there a way to easily specify multiple files with this tool?

I have found that you can specify space separated paths and it will run on all of them but this means you have to add all of the paths as arguments.

I believe linux has glob support in the command line so it will automatically expand the glob but windows does not.

A workaround is to write some code to call the tool for each file but this is slow.

The ideal solution is for the tool to either support glob strings and expand them or support directory inputs like Black does.

`unknown option: "caption"` error for `code-block` directive

When using this code :

.. code-block:: console
   :caption: Cloning the |comintboardimg| repository
   :name: clone-com-int

   $ git clone https://gitlab.com/xxxx/xxxx.git
   $ cd comboard-linux-image

And running rstfmt on my source folder using rstfmt source, I'm having the following error :

:40: (ERROR/3) Error in "code-block" directive:
unknown option: "caption".

This is also happening with .. code-block:: equivalent .. sourcecode::


  • rstfmt version : rstfmt 0.0.13
  • python3 version : Python 3.8.10

Unknown directive type "bibliography"

This package has helped a lot to format my rst files, but it seems to be having an issue with this:

docutils.utils.SystemMessage: :347: (ERROR/3) Unknown directive type "bibliography".

.. bibliography::
   :cited:
   :labelprefix:

In general it seems to not work too well with sphinxcontrib-bibtex as :cite: also leads to errors (ERROR/3) Unknown interpreted text role "cite".

Looking forward to carrying on using this library and thanks for all the great work so far!

Cannot check version of rstfmt binary

Hello,

something I found missing when I was adding it to my commit hook, is the ability to check the version used, if it's current. My formatting and commit hooks check the versions of isort, black, pylint etc. against the requirements file, so make sure nobody misses out on an update and uses a tool that potentially undoes things or does it incorrectly.

Since it may use a rstfmt.exe on Windows, there is no real way to know which Python it belongs to, so asking pip is not a good idea. The rstfmt package has no version attribute. I would have liked to find __version__ set, and as I added a plugin for that in Nuitka recently, using something like pkg_resources.get_distribution("rstfmt").parsed_version would be a good addition, and means you have no double booking of the version, I think it will take what's in pip or setup.py somehow. But I would prefer a --version command line flag for that to be output.

I also found that a style of execution, with python -m rstfmt would be really nice to have. It allows me to know exactly which Python binary is used and most tools support that. It really only needs a __main__.py in your package.

For now though, I am unable to check the rstfmt version and will have to live without a version check. But please add it. :)

Support for ..raw: pass through is needed

I am very excited, I found this tool, however I have a file where it crashes, on what seems to be incompleteness.

In my Nuitka (http://nuitka.net) User Manual I have this:

.. raw:: pdf

PageBreak oneColumn
SetPageCounter 1

This gives ValueError: Unknown node type raw! and that's fair. I guess, it's needed to pass through stuff that is backend specific, like here for rst2pdf only.

I can remove this code, and only insert it when I render with rst2pdf, but I would like to avoid that of course.

Substitution with images do not work properly

Hello,

I am using this: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#substitution-definitions

My example is this:

Debian/Ubuntu/Mint
~~~~~~~~~~~~~~~~~~

* |DEBIAN_LOGO| |UBUNTU_LOGO| |MINT_LOGO| Stable: Debian/Ubuntu/Mint
  repositories

.. |DEBIAN_LOGO| image:: images/debian.png

.. |UBUNTU_LOGO| image:: images/ubuntu.png

.. |MINT_LOGO| image:: images/mint.png

on my download page, this should work, but gives a traceback like this:

:588: (WARNING/2) Substitution definition "DEBIAN_LOGO" empty or invalid.

.. |DEBIAN_LOGO| image:: images/debian.png

Traceback (most recent call last):
  File "/usr/local/bin/rstfmt", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/rstfmt/main.py", line 40, in main
    doc = rstfmt.parse_string(inp)
  File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 752, in parse_string
    parser.parse(s, doc)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/__init__.py", line 191, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 172, in run
    input_source=document['source'])
  File "/usr/lib/python3/dist-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/lib/python3/dist-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 2754, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 328, in section
    self.new_subsection(title, lineno, messages)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 396, in new_subsection
    node=section_node, match_titles=True)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 283, in nested_parse
    node=node, match_titles=match_titles)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 197, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/lib/python3/dist-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/lib/python3/dist-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 2329, in explicit_markup
    self.explicit_list(blank_finish)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 2359, in explicit_list
    match_titles=self.state_machine.match_titles)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 320, in nested_list_parse
    node=node, match_titles=match_titles)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 197, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/usr/lib/python3/dist-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/usr/lib/python3/dist-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 2632, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 2339, in explicit_construct
    return method(self, expmatch)
  File "/usr/lib/python3/dist-packages/docutils/parsers/rst/states.py", line 2060, in substitution_def
    source=src, line=srcline)
  File "/usr/lib/python3/dist-packages/docutils/utils/__init__.py", line 221, in warning
    return self.system_message(self.WARNING_LEVEL, *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 274, in system_message
    msg = super().system_message(level, message, *children, **kwargs)
  File "/usr/lib/python3/dist-packages/docutils/utils/__init__.py", line 194, in system_message
    raise SystemMessage(msg, level)
docutils.utils.SystemMessage: :588: (WARNING/2) Substitution definition "DEBIAN_LOGO" empty or invalid.

.. |DEBIAN_LOGO| image:: images/debian.png

Support for footnotes seems broken

In my Nuitka User Manual I have this code snippet:

Requirements
------------

- C Compiler: You need a compiler with support for C11 or alternatively
  for C++03 [#]_

The crash is this:

File "/usr/local/bin/rstfmt", line 10, in
sys.exit(main())
File "/usr/local/lib/python3.7/dist-packages/rstfmt/main.py", line 53, in main
output = rstfmt.format_node(args.width, doc)
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 682, in format_node
return "\n".join(fmt(node, FormatContext(0, width, "", [], 0))) + "\n"
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 459, in document
yield from chain_intersperse("", fmt_children(node, ctx))
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 75, in chain_intersperse
yield from x
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 455, in section
yield from chain_intersperse("", fmt_children(node, ctx.in_section()))
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 75, in chain_intersperse
yield from x
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 348, in bullet_list
yield from Formatters._list(node, ctx.with_bullet("- "))
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 340, in _list
subs = [list(fmt(c, ctx)) for c in node.children]
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 340, in
subs = [list(fmt(c, ctx)) for c in node.children]
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 363, in list_item
for first, c in enum_first(chain_intersperse("", fmt_children(node, ctx))):
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 75, in chain_intersperse
yield from x
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 414, in paragraph
yield from wrap_text(ctx.width, chain(fmt_children(node, ctx)))
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 165, in wrap_text
items = list(items)
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 208, in
return (fmt(c, ctx) for c in node.children)
File "/usr/local/lib/python3.7/dist-packages/rstfmt/rstfmt.py", line 675, in fmt
raise ValueError(f"Unknown node type {type(node).name}!")
ValueError: Unknown node type footnote_reference!

From the value error exception test, I can deduce that the code in question, is at least parsing it correctly, but then doesn't know how to format it. Hopefully that means it's easy to add.

I was using version 0.0.6 when this happened and Debian 10, but I don't think the later matters. I used pip to install it.

pre-commit hook metadata was added but never released

Using this repository as a sourc for a pre-commit hook currently requires using the "master" tag, because there is no tag which includes the .pre-commit-hooks.yaml file. That's a problem, because, as pre-commit puts it:

[WARNING] The 'rev' field of repo 'https://github.com/dzhu/rstfmt' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: pre-commit autoupdate often fixes this.

So, it'd be handy if there could be a v0.0.12 bump. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.