timvink / mkdocs-charts-plugin

Mkdocs plugin to add plots from data using vegalite
https://timvink.github.io/mkdocs-charts-plugin/
MIT License
84 stars 6 forks source link

Error - no attribute 'homepage' #12

Closed brianmcmillan closed 2 years ago

brianmcmillan commented 2 years ago

I'm trying to setup the plugin and I get the following error in the console log. ERROR - Error building page 'docs/WIP/index.md': 'ChartsPlugin' object has no attribute 'homepage'

The MkDocs server does not throw an error when I start the server with the following config.

mkdocs.yml

site_name: Project Documentation
site_url: https://example.com/
theme: 
  name: material
  features:
    - navigation.tabs  
    - navigation.tabs.sticky
    - navigation.expand
    - navigation.indexes
  icon:
    logo: material/map 
plugins:
  - search:
      lang: en  
  - charts:
      vega_theme: default
      vega_renderer: "canvas"
markdown_extensions:
  - meta
  - tables
  - admonition
  - pymdownx.details
  - pymdownx.keys
  - pymdownx.inlinehilite
  - pymdownx.snippets 
  - pymdownx.tasklist:
      custom_checkbox: true
  - pymdownx.highlight:
      anchor_linenums: true
      linenums: true  
  - pymdownx.tabbed:
      alternate_style: true 
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid
          format: !!python/name:pymdownx.superfences.fence_code_format
        - name: vegalite
          class: vegalite
          format: !!python/name:mkdocs_charts_plugin.fences.fence_vegalite
extra_javascript:
  - https://unpkg.com/tablesort@5.3.0/dist/tablesort.min.js
  - javascripts/tablesort.js          
  - https://cdn.jsdelivr.net/npm/vega@5
  - https://cdn.jsdelivr.net/npm/vega-lite@5
  - https://cdn.jsdelivr.net/npm/vega-embed@6

However, when I create a new document in a sub-directory, it throws an error.

/docs/WIP/index.md:

## Vega-Lite

```vegalite
{
  "description": "A simple bar chart with embedded data.",
  "data": {
    "values": [
      {"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
      {"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
      {"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
    ]
  },
  "mark": {"type": "bar", "tooltip": true},
  "encoding": {
    "x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}},
    "y": {"field": "b", "type": "quantitative"}
  }
}
<closing back ticks>

Full Terminal output:

$ ~/.pyenv/versions/documentation_templates/bin/mkdocs serve
INFO     -  Building documentation...
INFO     -  Cleaning site directory
ERROR    -  Error building page 'WIP/index.md': 'ChartsPlugin' object has no attribute 'homepage'
Traceback (most recent call last):
  File "/Users/brianmcmillan/.pyenv/versions/documentation_templates/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/mkdocs/__main__.py", line 181, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 63, in serve
    config = builder()
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 58, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/mkdocs/commands/build.py", line 314, in build
    _build_page(file.page, config, doc_files, nav, env, dirty)
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/mkdocs/commands/build.py", line 220, in _build_page
    output = config['plugins'].run_event(
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/mkdocs_charts_plugin/plugin.py", line 80, in on_post_page
    return self.add_javascript_variables(output, page, config)
  File "/Users/brianmcmillan/.pyenv/versions/3.10.2/envs/documentation_templates/lib/python3.10/site-packages/mkdocs_charts_plugin/plugin.py", line 105, in add_javascript_variables
    path_to_homepage = self.homepage.url_relative_to(page.file)
AttributeError: 'ChartsPlugin' object has no attribute 'homepage'
brianmcmillan commented 2 years ago

Closing this issue. I tried a few changes to the mkdocs.yml file and it now appears to be working perfectly. The diffs are also identical. Sorry to bother you.

BTW - This is FANTASTIC and exactly what I was looking for.

timvink commented 2 years ago

Happy to see the issue solved itself :)

BTW - This is FANTASTIC and exactly what I was looking for.

Thanks! Happy to hear it's helpful for someone else also!