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

[insider] blog post plugin breaks with custom nav key #4348

Closed
5 tasks done
vwxyzjn opened this issue Sep 13, 2022 · 7 comments
Closed
5 tasks done

[insider] blog post plugin breaks with custom nav key #4348

vwxyzjn opened this issue Sep 13, 2022 · 7 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@vwxyzjn
Copy link

vwxyzjn commented Sep 13, 2022

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

site_name: My Blog
theme:
  name: material
plugins:
  - meta
  - blog:
      blog_dir: . 
  - search
  - tags
nav:
  - index.md

works but not

site_name: My Blog
theme:
  name: material
plugins:
  - meta
  - blog:
      blog_dir: . 
  - search
  - tags
nav:
  - Overview: index.md

Expected behaviour

Should work without error

Actual behaviour

site_name: My Blog
theme:
  name: material
plugins:
  - meta
  - blog:
      blog_dir: . 
  - search
  - tags
nav:
  - Overview: index.md

produces

(cleanrl-py3.9) ➜  test3 git:(jax-ppo-envpool-atari) ✗ mkdocs serve
INFO     -  Building documentation...
INFO     -  Cleaning site directory
Traceback (most recent call last):
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/__main__.py", line 181, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 63, in serve
    config = builder()
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 58, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 282, in build
    files = config['plugins'].run_event('files', files, config=config)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/material/plugins/blog/plugin.py", line 272, in on_files
    root.append({ name: data })

Steps to reproduce

Follow tutorial at https://squidfunk.github.io/mkdocs-material/setup/setting-up-a-blog/ and then use

site_name: My Blog
theme:
  name: material
plugins:
  - meta
  - blog:
      blog_dir: . 
  - search
  - tags
nav:
  - Overview: index.md

as the mkdocs.yml

Package versions

N/A. Using the latest fix from #4345

Configuration

site_name: My Blog
theme:
  name: material
plugins:
  - meta
  - blog:
      blog_dir: . 
  - search
  - tags
nav:
  - Overview: index.md

System information

n/a

@squidfunk squidfunk added the bug Issue reports a bug label Sep 13, 2022
@squidfunk
Copy link
Owner

Thanks for reporting! Fixed in squidfunk/mkdocs-material-insiders@f92137cab33284ad09c10e8dc4940c7f5e2d304b.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Sep 13, 2022
@squidfunk
Copy link
Owner

squidfunk commented Sep 13, 2022

Released as part of 8.4.4+insiders-4.23.2.

@vwxyzjn
Copy link
Author

vwxyzjn commented Sep 15, 2022

This problem persists in the latest commit (c70dcb54465092f7f527a04385c79597e990133e)

Collecting git+https://****@github.com/squidfunk/mkdocs-material-insiders.git
  Cloning https://****@github.com/squidfunk/mkdocs-material-insiders.git to /tmp/pip-req-build-gs5_ou61
  Running command git clone --filter=blob:none --quiet 'https://****@github.com/squidfunk/mkdocs-material-insiders.git' /tmp/pip-req-build-gs5_ou61
  Resolved https://****@github.com/squidfunk/mkdocs-material-insiders.git to commit c70dcb54465092f7f527a04385c79597e990133e
  Preparing metadata (setup.py) ... done
(cleanrl-py3.9) ➜  test3 git:(jax-ppo-envpool-atari) ✗ mkdocs serve                 
INFO     -  Building documentation...
INFO     -  Cleaning site directory
Traceback (most recent call last):
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/__main__.py", line 181, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 63, in serve
    config = builder()
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 58, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 282, in build
    files = config['plugins'].run_event('files', files, config=config)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/material/plugins/blog/plugin.py", line 271, in on_files
    root.append({ name: data })
AttributeError: 'NoneType' object has no attribute 'append'

but if i do pip install --upgrade git+https://xxxx@github.com/squidfunk/mkdocs-material-insiders.git@f92137cab33284ad09c10e8dc4940c7f5e2d304b then the issue was fixed

@vwxyzjn
Copy link
Author

vwxyzjn commented Sep 15, 2022

It also gives me the same error if I use the default file structure like

  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/material/plugins/blog/plugin.py", line 272, in on_files
    root.append({ name: data })
AttributeError: 'NoneType' object has no attribute 'append'
(cleanrl-py3.9) ➜  test3 git:(jax-ppo-envpool-atari) ✗ tree
.
├── docs
│   ├── blog
│   │   ├── index.md
│   │   └── posts
│   │       └── hello_world.md
│   ├── dummy.md
│   └── index.md
└── mkdocs.yml
site_name: My Blog
theme:
  name: material
plugins:
  - meta
  - blog
      # blog_dir: . 
  - search
  - tags
nav:
  - Overview: index.md

@squidfunk
Copy link
Owner

Thanks for reporting. That is very weird, as other users reported this problem is fixed now. Please provide a self-contained reproduction and attach it here as a zip. Also, please specify what system you're using (Windows? You didn't specify it in the original issue, but it's highly relevant).

@squidfunk squidfunk reopened this Sep 15, 2022
@squidfunk squidfunk added needs input Issue needs further input by the reporter and removed resolved Issue is resolved, yet unreleased if open labels Sep 15, 2022
@squidfunk
Copy link
Owner

squidfunk commented Sep 15, 2022

Okay, I can reproduce it – it's a configuration error: the blog must be contained in a section, not a separate entry:

This doesn't work:

nav:
  - Overview: index.md

This works:

nav:
  - Overview:
    - index.md

Note that your directory layout is also wrong. You're telling the plugin that the blog lives in ., but your docs_dir says that it lives in blog:

This is wrong:

.
├── docs
│   ├── blog
│   │   ├── index.md
│   │   └── posts
│   │       └── hello_world.md
│   ├── dummy.md
│   └── index.md
└── mkdocs.yml

This should work:

.
├── docs
│   ├── posts
│   │    └── hello_world.md
│   ├── dummy.md
│   └── index.md
└── mkdocs.yml

I'm closing the issue, but I'll check if we can improve error reporting next time I work on the plugin.

@squidfunk squidfunk added resolved Issue is resolved, yet unreleased if open and removed needs input Issue needs further input by the reporter labels Sep 15, 2022
@squidfunk
Copy link
Owner

@vwxyzjn there was indeed another bug, that was fixed in squidfunk/mkdocs-material-insiders@27caebdab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants