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

Mkdocs fail for a specific module, crashing the whole build #365

Closed
shaypal5 opened this issue Jan 20, 2022 · 5 comments
Closed

Mkdocs fail for a specific module, crashing the whole build #365

shaypal5 opened this issue Jan 20, 2022 · 5 comments
Labels
unconfirmed This bug was not reproduced yet

Comments

@shaypal5
Copy link

Describe the bug
Mkdocs fails for a specific module, crashing the whole build (see full stacktrace below).

The skintegrate.md file in question is very simple:

# Scikit-learn Integrations

::: pdpipe.skintegrate

I have nine (!) other identically-structured markdown files residing in the same directory, with the same exact syntax (a header, one blank line, one mkdocstrings command pointing at a module of my package. That's it) just pointing to different modules. Also, all are referenced in the same way in the mkdocs.yml.

If I comment out the mkdocstring line the page renders:

# Scikit-learn Integrations

<!-- ::: pdpipe.skintegrate -->

See the resulting page: https://pdpipe.readthedocs.io/en/latest/reference/skintegrate/
image

It's also not a collection issue, because if I mess with the module name (to get a non-existent module, say skintegr) I get a different error (so this NOT the stacktrace of my error; continue downwards to find it):

INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /home/docs/checkouts/readthedocs.org/user_builds/pdpipe/checkouts/latest/_build/html
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.basic_stages.DropDuplicates: No type annotation for parameter 'exclude_columns'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.basic_stages.RowDrop: No type annotation for parameter 'exclude_columns'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.basic_stages.ValDrop: No type annotation for parameter 'exclude_columns'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.basic_stages.ValKeep: No type annotation for parameter 'exclude_columns'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.core.ColumnsBasedPipelineStage: Empty parameter section
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.core.PdPipeline: No type annotation for parameter 'transform_getter'
�[31mERROR    -  �[0mmkdocstrings.extension: module 'pdpipe' has no attribute 'skintegr'
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/pytkdocs/cli.py", line 205, in main
    output = json.dumps(process_json(line))
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/pytkdocs/cli.py", line 114, in process_json
    return process_config(json.loads(json_input))
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/pytkdocs/cli.py", line 91, in process_config
    obj = loader.get_object_documentation(path, members)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/pytkdocs/loader.py", line 355, in get_object_documentation
    leaf = get_object_tree(dotted_path, self.new_path_syntax)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/pytkdocs/loader.py", line 281, in get_object_tree
    obj = getattr(current_node.obj, obj_name)
AttributeError: module 'pdpipe' has no attribute 'skintegr'

�[31mERROR    -  �[0mError reading page 'reference/skintegrate.md':
�[31mERROR    -  �[0mCould not collect 'pdpipe.skintegr'

Aborted with a BuildError!

Expected behavior
A clear and concise description of what you expected to happen.

Full Stacktrace

INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /home/docs/checkouts/readthedocs.org/user_builds/pdpipe/checkouts/latest/_build/html
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.basic_stages.DropDuplicates: No type annotation for parameter 'exclude_columns'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.basic_stages.RowDrop: No type annotation for parameter 'exclude_columns'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.basic_stages.ValDrop: No type annotation for parameter 'exclude_columns'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.basic_stages.ValKeep: No type annotation for parameter 'exclude_columns'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.core.ColumnsBasedPipelineStage: Empty parameter section
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.core.PdPipeline: No type annotation for parameter 'transform_getter'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.skintegrate.PdPipelineAndSklearnEstimator: No type annotation for parameter 'model'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.skintegrate.PdPipelineAndSklearnEstimator: No type annotation for parameter 'Example'
�[33mWARNING  -  �[0mmkdocstrings.handlers.python: pdpipe.skintegrate.PdPipelineAndSklearnEstimator: No type annotation for parameter '----------'
�[31mERROR    -  �[0mError reading page 'reference/skintegrate.md': 'NoneType' object has no attribute 'strip'
Traceback (most recent call last):
  File "/home/docs/.asdf/installs/python/3.8.12/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/docs/.asdf/installs/python/3.8.12/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocs/__main__.py", line 221, in <module>
    cli()
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocs/__main__.py", line 187, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocs/commands/build.py", line 292, in build
    _populate_page(file.page, config, files, dirty)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocs/commands/build.py", line 174, in _populate_page
    page.render(config, files)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocs/structure/pages.py", line 174, in render
    self.content = md.convert(self.markdown)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/markdown/core.py", line 264, in convert
    root = self.parser.parseDocument(self.lines).getroot()
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/markdown/blockparser.py", line 90, in parseDocument
    self.parseChunk(self.root, '\n'.join(lines))
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/markdown/blockparser.py", line 105, in parseChunk
    self.parseBlocks(parent, text.split('\n\n'))
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/markdown/blockparser.py", line 123, in parseBlocks
    if processor.run(parent, blocks) is not False:
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocstrings/extension.py", line 120, in run
    html, handler, data = self._process_block(identifier, block, heading_level)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocstrings/extension.py", line 199, in _process_block
    rendered = handler.renderer.render(data, rendering)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocstrings/handlers/python.py", line 96, in render
    return template.render(
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocstrings/templates/python/material/module.html", line 53, in top-level template code
    {% include "children.html" with context %}
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocstrings/templates/python/material/children.html", line 30, in top-level template code
    {% include "class.html" with context %}
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocstrings/templates/python/material/class.html", line 54, in top-level template code
    {% include "docstring.html" with context %}
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocstrings/templates/python/material/docstring.html", line 12, in top-level template code
    {% include "parameters.html" with context %}
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocstrings/templates/python/material/parameters.html", line 17, in top-level template code
    <td>{{ parameter.description|convert_markdown(heading_level, html_id) }}</td>
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/mkdocstrings/handlers/base.py", line 158, in do_convert_markdown
    return Markup(self._md.convert(text))
  File "/home/docs/checkouts/readthedocs.org/user_builds/pdpipe/envs/latest/lib/python3.8/site-packages/markdown/core.py", line 248, in convert
    if not source.strip():
AttributeError: 'NoneType' object has no attribute 'strip'

Information (please complete the following information):

  • OS: Builds on readthedocs.io
  • Browser: Irrelevant
  • mkdocstrings version: mkdocstrings-0.17.0
@shaypal5 shaypal5 added the unconfirmed This bug was not reproduced yet label Jan 20, 2022
@pawamoy
Copy link
Member

pawamoy commented Jan 20, 2022

What docstring style do you use? Did you configure mkdocstrings to use it? I see ----------- is detected as a parameter, so I suspect Numpydoc style. If the formatting/parsing is wrong, then the parameter description is None and it breaks the convert_markdown filter. Could I see your mkdocs.yml and your skintegrate module code (the docstrings particularly)?

@shaypal5
Copy link
Author

I use mkdocs-material, and the whole site renders perfectly.

I configured mkdocstrings to use the numpy style, and it renders all the API perfectly:
https://pdpipe.readthedocs.io/en/latest/reference/col_generation/

Here's my .readthedocs.mkdocs.yml file:

site_name: pdpipe
site_url: https://pdpipe.readthedocs.io/en/latest/
repo_name: pdpipe
repo_url: https://github.com/pdpipe/pdpipe
edit_uri: edit/master/doc
docs_dir: docs
copyright: © Copyright 2022 Shay Palachy | All Rights Reserved.
nav:
  - Home:
      - index.md
      - More on pdpipe: more.md
  - Getting Started:
      - Installation: starting/install.md
      - First Use: starting/first_use.md
      - Pipeline Stages: starting/stages.md
      - Pipelines: starting/pipelines.md
      - Types of Stages: starting/types.md
      - Conditions: starting/cond.md
      - Column Qualifiers: starting/cq.md
      - Wrappers: starting/wrappers.md
  - Develop:
      - develop/adhoc.md
      - develop/custom.md
  - Tutorials:
      - tutorials/index.md
      - Basic Usage: tutorials/basic.md
  - API Reference:
      - Core: reference/core.md
      - Basic Stages: reference/basic.md
      - Column Generation: reference/col_generation.md
      - Scikit-learn Stages: reference/sklearn.md
      - Scikit-learn Integrations: reference/skintegrate.md
      - Text Stages: reference/text.md
      - NLTK Stages: reference/nltk.md
      - Conditions: reference/cond.md
      - Column Qualifiers: reference/cq.md
      - Wrappers: reference/wrappers.md

theme:
  name: material
  features:
    - navigation.tabs
    - navigation.indexes
    - navigation.top
    # - navigation.instant
    - navigation.tracking
    - header.autohide
    - content.code.annotate
  icon:
    repo: fontawesome/brands/github
  language: en
  font:
    text: Roboto
    code: Roboto Mono
  favicon: images/logo.png
  logo: 'images/white_logo.png'
  palette:
    - media: "(prefers-color-scheme: light)"
      scheme: default
      primary: green
      accent: light green
      toggle:
        icon: material/lightbulb
        name: Switch to dark mode
    - media: "(prefers-color-scheme: dark)"
      scheme: slate
      primary: green
      accent: light green
      toggle:
        icon: material/lightbulb-outline
        name: Switch to light mode

plugins:
  - search
  - git-revision-date
  - awesome-pages
  - mkdocstrings:
      default_handler: python
      handlers:
        python:
          rendering:
            show_source: true
            show_category_heading: true
            members_order: source
            show_if_no_docstring: true
          selection:
            docstring_style: numpy
            filters: ["!^_"]
# for how to adjust the filters selecting which functions get collected, see:
# https://mkdocstrings.github.io/pytkdocs/#configuration


# for code blocks syntax highlighting
markdown_extensions:
  - admonition
  - footnotes
  - codehilite
  - pymdownx.highlight:
      anchor_linenums: true
  - pymdownx.details
  - pymdownx.inlinehilite
  - pymdownx.snippets
  - pymdownx.superfences


# use icon paths the match the folder structure in the fontawesome repo:
# https://github.com/FortAwesome/Font-Awesome/tree/master/svgs
extra:
  social:
    - icon: fontawesome/brands/github
      link: https://github.com/pdpipe/pdpipe
    - icon: fontawesome/solid/comments
      link: https://github.com/pdpipe/pdpipe/discussions
    - icon: fontawesome/brands/gitter
      link: https://gitter.im/pdpipe/community
    - icon: fontawesome/brands/python
      link: https://pypi.org/project/pdpipe/
    - icon: fontawesome/brands/twitter
      link: https://twitter.com/shaypal5

extra_css:
  - "mkdocs/css/termynal.css"
  - "mkdocs/css/custom.css"
  - "mkdocs/css/extra.css"
  - "mkdocs/css/admonitions.css"

extra_javascript:
  - "mkdocs/js/termynal.js"
  - "mkdocs/js/custom.js"
  - "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML"

@shaypal5
Copy link
Author

shaypal5 commented Jan 20, 2022

But the ---------- as a parameter is a huge hint! I bet I misaligned it, and it has too little/many characters!

@shaypal5
Copy link
Author

Indeed! Too many - characters! Aligning it solved the problem:
https://pdpipe.readthedocs.io/en/latest/reference/skintegrate/

Thanks for the awesome and speedy reply! <3 <3

@pawamoy
Copy link
Member

pawamoy commented Jan 20, 2022

Great 🥳
You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed This bug was not reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants