Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

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

Closed
matt-everett opened this issue Oct 1, 2019 · 19 comments

Comments

@matt-everett
Copy link

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
Copy link
Author

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

@clayrisser
Copy link
Owner

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

@matt-everett
Copy link
Author

@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!

@clayrisser
Copy link
Owner

Ok sounds great. Thanks

@SwampFalc
Copy link

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
Copy link

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

@clayrisser
Copy link
Owner

Any ideas for a fix?

@SwampFalc
Copy link

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

@clayrisser
Copy link
Owner

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

@clayrisser
Copy link
Owner

The documentation definitely can use improvement.

@SwampFalc
Copy link

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

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

@clayrisser
Copy link
Owner

Ok, thanks. I'll improve that.

@matt-everett
Copy link
Author

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?

@clayrisser
Copy link
Owner

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

@ethantang95
Copy link

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

@clayrisser clayrisser pinned this issue Nov 12, 2019
@clayrisser
Copy link
Owner

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.

@SwampFalc
Copy link

SwampFalc commented Nov 12, 2019 via email

@clayrisser
Copy link
Owner

clayrisser commented Nov 13, 2019

Thanks @SwampFalc

I’ll clean up the conf.py file

@clayrisser
Copy link
Owner

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

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

No branches or pull requests

4 participants