timothycrosley / portray

Your Project with Great Documentation.
MIT License
860 stars 72 forks source link

AttributeError: 'NoneType' object has no attribute 'replace' #103

Open sbrugman opened 1 year ago

sbrugman commented 1 year ago

The following error occurs when running portray in_browser out-of-the-box:

Done Copying source documentation to temporary compilation directory
Traceback (most recent call last):
  File "/venv/bin/portray", line 8, in <module>
    sys.exit(__hug__.cli())
  File "/venv/lib/python3.9/site-packages/hug/api.py", line 441, in __call__
    result = self.commands.get(command)()
  File "/venv/lib/python3.9/site-packages/hug/interface.py", line 650, in __call__
    raise exception
  File "/venv/lib/python3.9/site-packages/hug/interface.py", line 646, in __call__
    result = self.output(self.interface(**pass_to_function), context)
  File "/venv/lib/python3.9/site-packages/hug/interface.py", line 129, in __call__
    return __hug_internal_self._function(*args, **kwargs)
  File "/venv/lib/python3.9/site-packages/portray/api.py", line 65, in in_browser
    server(
  File "/venv/lib/python3.9/site-packages/portray/api.py", line 101, in server
    with render.documentation_in_temp_folder(project_config) as (sources_folder, docs_folder):
  File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/venv/lib/python3.9/site-packages/portray/render.py", line 150, in documentation_in_temp_folder
    pdocs(config["pdocs"])
  File "/venv/lib/python3.9/site-packages/portray/render.py", line 61, in pdocs
    pdocs_as_markdown(**config)
  File "/venv/lib/python3.9/site-packages/pdocs/api.py", line 83, in as_markdown
    pdocs.static.md_out(destination, roots, source=not exclude_source)
  File "/venv/lib/python3.9/site-packages/pdocs/static.py", line 88, in md_out
    out = pdocs.render.text(m, source=source)
  File "/venv/lib/python3.9/site-packages/pdocs/render.py", line 85, in text
    raw_text = _get_tpl("/text.mako").render(module=mod, show_source_code=source)
  File "/venv/lib/python3.9/site-packages/mako/template.py", line 439, in render
    return runtime._render(self, self.callable_, args, data)
  File "/venv/lib/python3.9/site-packages/mako/runtime.py", line 874, in _render
    _render_context(
  File "/venv/lib/python3.9/site-packages/mako/runtime.py", line 916, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/venv/lib/python3.9/site-packages/mako/runtime.py", line 943, in _exec_template
    callable_(context, *args, **kwargs)
  File "_text_mako", line 93, in render_body
  File "_text_mako", line 24, in function
  File "_text_mako", line 237, in render_function
AttributeError: 'NoneType' object has no attribute 'replace'

Any pointers on how to resolve this?

Dependencies: Python 3.9 portray==1.8.0 pdocs==1.2.0 mkdocs==1.3.1 mkdocs-gitbook==0.0.1 mkdocs-material==8.5.4 mkdocs-material-extensions==1.1.1 Mako==1.2.4 Markdown==3.3.7 MarkupSafe==2.1.1

labrunhosarodrigues commented 1 year ago

I am experiencing the same error, the same versions of portray, pdocs and mkdocs, but using python3.10 and the option as_html.

labrunhosarodrigues commented 1 year ago

@sbrugman in my case it was because of different formatting than what is defined in _text_mako. Namely, a Returns section with only the name of the retrieved variable, here mako expects a description field that is the None of the error. I also found the it does not support having a Raises section without the Returns section before it.

aeldaly-tc commented 1 year ago

Is a fix for this planned? I don't have either of those issues mentioned above. I do have lines like this though. Don't know if that causes an issue as well?

- Updates user in database
- Logs updated user
- Returns updated User object