sphinx-markdown-builder icon indicating copy to clipboard operation
sphinx-markdown-builder copied to clipboard

AttributeError: type object 'MarkdownBuilder' has no attribute 'supported'

Open matt-everett opened this issue 6 years ago • 18 comments
trafficstars

Hi, I'm running into a problem when I try to run this package.

I copied the conf.py example for sphinx 1.8 (I'm using 2.2) but needed to edit the example code as is seems a little out of date, it references a sphinx_markdown_parser module.

I'm running from tox with this command: - tox sphinx-build -M markdown containers/source {env:DOC_OUTPUT_FOLDER:'build'}/containersmd

Error

Exception occurred:
  File "/home/matt.everett/code/mkc/microservices/service-api/src/.tox/doc/lib/python3.7/site-packages/sphinx/registry.py", line 302, in add_source_parser
    if len(parser.supported) == 0:
AttributeError: type object 'MarkdownBuilder' has no attribute 'supported'

Log

# Sphinx version: 2.2.0
# Python version: 3.7.3 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.10.1
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
  File "/home/matt.everett/code/mkc/microservices/service-api/src/.tox/doc/lib/python3.7/site-packages/sphinx/cmd/build.py", line 275, in build_main
    args.tags, args.verbosity, args.jobs, args.keep_going)
  File "/home/matt.everett/code/mkc/microservices/service-api/src/.tox/doc/lib/python3.7/site-packages/sphinx/application.py", line 250, in __init__
    self.config.setup(self)
  File "/home/matt.everett/code/mkc/microservices/service-api/src/doc/containers/source/conf.py", line 63, in setup
    app.add_source_parser(MarkdownBuilder)
  File "/home/matt.everett/code/mkc/microservices/service-api/src/.tox/doc/lib/python3.7/site-packages/sphinx/application.py", line 1133, in add_source_parser
    self.registry.add_source_parser(*args, **kwargs)
  File "/home/matt.everett/code/mkc/microservices/service-api/src/.tox/doc/lib/python3.7/site-packages/sphinx/registry.py", line 302, in add_source_parser
    if len(parser.supported) == 0:
AttributeError: type object 'MarkdownBuilder' has no attribute 'supported'

matt-everett avatar Oct 01 '19 10:10 matt-everett

Please let me know if you need any other information about my setup to help diagnose this.

matt-everett avatar Oct 01 '19 10:10 matt-everett

Can you send me a link to the code where this fails and tell me how to reproduce it?

clayrisser avatar Oct 01 '19 17:10 clayrisser

@codejamninja, thanks for your response. Currently the code is deeply entrenched in a big proprietary codebase :( I'm going to try to put together a demo of the problem in a smaller package to make it possible to share. I'll hopefully get some time to work on it soon!

matt-everett avatar Oct 17 '19 09:10 matt-everett

Ok sounds great. Thanks

clayrisser avatar Oct 17 '19 11:10 clayrisser

Same error, except with different versions:

# Sphinx version: 1.8.5
# Python version: 2.7.16 (CPython)
# Docutils version: 0.15.2 release
# Jinja2 version: 2.10.3
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
  File "/home/ldt/.virtualenvs/fedpass-XgqykgRQ/local/lib/python2.7/site-packages/sphinx/cmd/build.py", line 303, in build_main
    args.tags, args.verbosity, args.jobs, args.keep_going)
  File "/home/ldt/.virtualenvs/fedpass-XgqykgRQ/local/lib/python2.7/site-packages/sphinx/application.py", line 241, in __init__
    self.config.setup(self)
  File "/home/ldt/Projects/fedpass/docs/conf.py", line 72, in setup
    app.add_source_parser(MarkdownBuilder)
  File "/home/ldt/.virtualenvs/fedpass-XgqykgRQ/local/lib/python2.7/site-packages/sphinx/application.py", line 1211, in add_source_parser
    self.registry.add_source_parser(*args, **kwargs)
  File "/home/ldt/.virtualenvs/fedpass-XgqykgRQ/local/lib/python2.7/site-packages/sphinx/registry.py", line 301, in add_source_parser
    if len(parser.supported) == 0:
AttributeError: type object 'MarkdownBuilder' has no attribute 'supported'

And the code from my conf.py where it starts:

from sphinx_markdown_builder import MarkdownBuilder

source_suffix = {
    '.rst': 'restructuredtext',
    '.md': 'markdown'
}

def setup(app):
    app.add_source_suffix('.md', 'markdown')
    app.add_source_parser(MarkdownBuilder)

SwampFalc avatar Oct 22 '19 08:10 SwampFalc

Small follow-up, I went into the sphinx source:

        if len(parser.supported) == 0:
            warnings.warn('Old source_parser has been detected. Please fill Parser.supported '
                          'attribute: %s' % parser.__name__,
                          RemovedInSphinx30Warning, stacklevel=3)

Clearly the parser API has changed (recently?). Unfortunately, their own error catching is failing a bit...

SwampFalc avatar Oct 22 '19 12:10 SwampFalc

Any ideas for a fix?

clayrisser avatar Oct 23 '19 05:10 clayrisser

Actually, yes. Why do you even have this code on the front page? I mean, all of that is to register a markdown parser, ie. to read markdown source files. And the point of this project is to build markdown output, no?

I removed all of that from my conf.py, ran "make markdown" and got the .md files I wanted as output...

SwampFalc avatar Oct 23 '19 07:10 SwampFalc

Can you paste in the chat the "front page" code you are referring to?

clayrisser avatar Oct 23 '19 08:10 clayrisser

The documentation definitely can use improvement.

clayrisser avatar Oct 23 '19 08:10 clayrisser

https://github.com/codejamninja/sphinx-markdown-builder

The first 3/4s of the "Usage" section, up until the line "Build markdown files with Makefile"

SwampFalc avatar Oct 23 '19 15:10 SwampFalc

Ok, thanks. I'll improve that.

clayrisser avatar Oct 24 '19 07:10 clayrisser

I've just tried @SwampFalc's advice (make markdown) and it does indeed build the output I want ... thanks very much!

It didn't convert the tables quite correctly but I'll raise a separate issue for that :)

@codejamninja do you still think this issue is relevant? It sounds like the docs need updating, but is the parser scenario relevant to your project if it's already producing markdown output? Would you prefer me to close this or do you want to continue tracking it?

matt-everett avatar Oct 25 '19 16:10 matt-everett

For now keep tracking it until I can look into deeper. I'm glad you were able to make it work.

clayrisser avatar Oct 25 '19 18:10 clayrisser

I can confirm this issue still exists with sphinx-build -M markdown <source dir> <output dir>. For my case, I cannot use make markdown because I need to call upon the sphinx module through python.

I have tested on both sphinx 2.0.0 and 1.8.0. Neither works and fails with the same issue that is stated by @matt-everett and @SwampFalc.

Is there any updates on fixing this issue?

Thank you

ethantang95 avatar Nov 08 '19 04:11 ethantang95

I'm really busy. I will try to get to it before the holidays. If you want to did into it feel free to. I just pinned this issue so I don't forget about it.

clayrisser avatar Nov 12 '19 06:11 clayrisser

The solution is to remove everything you added to your conf.py. None of it is needed for the correct operation of this module, it's a leftover from another module ( that I assume was forked to start this).

On Fri, Nov 8, 2019, 05:21 Ethan Tang [email protected] wrote:

I can confirm this issue still exists with sphinx-build -M markdown

. For my case, I cannot use make markdown because I need to call upon the sphinx module through python.

I have tested on both sphinx 2.0.0 and 1.8.0. Neither works and fails with the same issue that is stated by @matt-everett https://github.com/matt-everett and @SwampFalc https://github.com/SwampFalc.

Is there any updates on fixing this issue?

Thank you

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/codejamninja/sphinx-markdown-builder/issues/36?email_source=notifications&email_token=AE3Z3HAHN7DEFKHSYFQTTYLQSTSMBA5CNFSM4I4H3QJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDOV26Q#issuecomment-551378298, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE3Z3HHANJNMKP2NBA36DILQSTSMBANCNFSM4I4H3QJQ .

SwampFalc avatar Nov 12 '19 12:11 SwampFalc

Thanks @SwampFalc

I’ll clean up the conf.py file

clayrisser avatar Nov 13 '19 19:11 clayrisser

DISCONTINUED: This project is no longer maintained. The active version of this project is now being maintained at liran-funaro/sphinx-markdown-builder.

clayrisser avatar Jun 24 '23 21:06 clayrisser