backstage / mkdocs-techdocs-core

The core MkDocs plugin used by Backstage's TechDocs as a wrapper around multiple MkDocs plugins and Python Markdown extensions
Apache License 2.0
83 stars 61 forks source link

Version 1.1.0 breaks with my docs #66

Closed gmambro closed 2 years ago

gmambro commented 2 years ago

Hello,

my pipeline stopped working as soon as started using 1.1.0.

This is the traceback
Traceback (most recent call last):
  File "xxx/venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "xxx//venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "xxx/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "xxx//venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "xxx/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "xxx/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "xxx/venv/lib/python3.10/site-packages/mkdocs/__main__.py", line 192, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "xxx/venv/lib/python3.10/site-packages/mkdocs/commands/build.py", line 257, in build
    config = config['plugins'].run_event('config', config)
  File "xxx//venv/lib/python3.10/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/Users/gabriele/jimdo/aws-msk-engineering/venv/lib/python3.10/site-packages/src/core.py", line 49, in on_config
    theme_override = config["theme"].copy()
AttributeError: 'Theme' object has no attribute 'copy'

my mkdocs.yml looks like this

site_name: My docs
site_description: Documentation for my project
plugins:
  - techdocs-core

markdown_extensions:
  - toc:
      permalink: "#"

nav:
 - Overview: overview.md
 - User Guide: user_guide.md

Reverting to 1.0.2 solved the problem

gavinclarkeuk commented 2 years ago

I think this issue was introduced with https://github.com/backstage/mkdocs-techdocs-core/commit/ddd8d28547e1ec6eb3dcd05b019c21307d45bc53

Changing the line

theme_override = config["theme"].copy()

to

theme_override = config["theme"]

locally seemed to fix things, but I'm not enough of a python/techdocs expert to know if that is a safe thing to do

rmanny commented 2 years ago

As a sidenote, I have seen this pipeline error a few times before as well:

caused by unknown error 'Command mkdocs failed, exit code: 1'

Which is obviously not very helpful. Is there any way to bubble the real mkdocs error up? So it's easier to tell if it's a logic error like this

iamEAP commented 2 years ago

Hey folks! Thanks for your patience, and for reporting.

Just released v1.1.1 with a very narrow fix (and added a workflow to run unit tests that will hopefully help reduce issues like this cropping up again in the future). We have end-to-end tests in the main Backstage monorepo that started failing after 1.1.0, which are now passing again after releasing 1.1.1. So I'm confident bumping will resolve the issue for you!

If you happen to rely on the theme override capabilities introduced in v1.1.0, those may still not be working 100%, but at least the docs generation is working again.

...Is there any way to bubble the real mkdocs error up? So it's easier to tell if it's a logic error like this

@rmanny great point! My guess is that the TechDocs CLI likely treats things differently compared with the log output in Backstage frontend (if you've got it configured to run that way). An issue in the main Backstage monorepo with that detail (whether it's TechDocs CLI or the Backstage UI) would be a good first step.