liran-funaro / sphinx-markdown-builder

A Sphinx extension to add markdown generation support.
https://pypi.org/project/sphinx-markdown-builder
MIT License
41 stars 19 forks source link

[BUG] AssertionError when using with httpdomain extension #12

Closed danielnelson closed 10 months ago

danielnelson commented 11 months ago

Describe the bug

When building docs with this httpdomain directive, which is their basic usage example:

.. http:get:: /users/(int:user_id)/posts/(tag)

I get this error:

  File "/home/dbn/usr/py-3.12/lib/python3.12/site-packages/docutils/nodes.py", line 199, in walkabout
    visitor.dispatch_departure(self)
  File "/home/dbn/usr/py-3.12/lib/python3.12/site-packages/sphinx/util/docutils.py", line 599, in dispatch_departure
    method(node)
  File "/home/dbn/usr/py-3.12/lib/python3.12/site-packages/sphinx_markdown_builder/translator.py", line 159, in _pop_context
    ctx.add(last_ctx.make(), last_ctx.params.prefix_eol, last_ctx.params.suffix_eol)
  File "/home/dbn/usr/py-3.12/lib/python3.12/site-packages/sphinx_markdown_builder/contexts.py", line 135, in add
    self.force_eol(prefix_eol)
  File "/home/dbn/usr/py-3.12/lib/python3.12/site-packages/sphinx_markdown_builder/contexts.py", line 115, in force_eol
    missing_eol = self._count_missing_eol()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dbn/usr/py-3.12/lib/python3.12/site-packages/sphinx_markdown_builder/contexts.py", line 94, in _count_missing_eol
    for value in self._iter_reverse_char():
  File "/home/dbn/usr/py-3.12/lib/python3.12/site-packages/sphinx_markdown_builder/contexts.py", line 82, in _iter_reverse_char
    for value in reversed(self.content):
                          ^^^^^^^^^^^^
  File "/home/dbn/usr/py-3.12/lib/python3.12/site-packages/sphinx_markdown_builder/contexts.py", line 189, in content
    assert self.is_parameter
AssertionError

If I modify the line like so, then the error no longer occurs.

- .. http:get:: /users/(int:user_id)/posts/(tag)
+ .. http:get:: /users/(user_id)/posts/(tag)

To Reproduce Steps to reproduce the behavior:

  1. Install packages sphinxcontrib-httpdomain
  2. Add it to the sphinx extensions:
    extensions = [
       "sphinx_markdown_builder",
       "sphinxcontrib.httpdomain",
    ]
  3. sphinx-build -M markdown docs _build

Expected behavior Successful documentation build

Environment (please complete the following information):

Additional context Add any other context about the problem here.

liran-funaro commented 10 months ago

Thank you for the report. I'm sorry it took some time to reply. I attended to this issue in version 0.6.6. Please check it out and update here if this works for you.

danielnelson commented 10 months ago

Works great, thanks!