pawelsikora / mkdocs-with-confluence

MkDocs plugin for uploading markdown documentation to Confluence via Confluence REST API
MIT License
67 stars 33 forks source link

Cannot build minimal example #2

Closed jannismain closed 2 years ago

jannismain commented 2 years ago

I have tried to publish the minimal example provided by mkdocs new . to confluence using mkdocs-with-confluence without success:

$ WITH_CONFLUENCE=1 mkdocs build
INFO    -  Mkdocs With Confluence: Exporting MKDOCS pages to Confluence turned ON by var {env_name}==1!
INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /Users/mkj/Developer/playgrounds/mkdocs/mkdocs-confluence-examples/site
Number of Files: 1
Traceback (most recent call last):
  File "/Users/mkj/.pyenv/versions/mkdocs-with-confluence/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/Users/mkj/.pyenv/versions/3.9.7/envs/mkdocs-with-confluence/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/mkj/.pyenv/versions/3.9.7/envs/mkdocs-with-confluence/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/mkj/.pyenv/versions/3.9.7/envs/mkdocs-with-confluence/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/mkj/.pyenv/versions/3.9.7/envs/mkdocs-with-confluence/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/mkj/.pyenv/versions/3.9.7/envs/mkdocs-with-confluence/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/mkj/.pyenv/versions/3.9.7/envs/mkdocs-with-confluence/lib/python3.9/site-packages/mkdocs/__main__.py", line 187, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/Users/mkj/.pyenv/versions/3.9.7/envs/mkdocs-with-confluence/lib/python3.9/site-packages/mkdocs/commands/build.py", line 287, in build
    nav = config['plugins'].run_event('nav', nav, config=config, files=files)
  File "/Users/mkj/.pyenv/versions/3.9.7/envs/mkdocs-with-confluence/lib/python3.9/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/Users/mkj/.pyenv/versions/3.9.7/envs/mkdocs-with-confluence/lib/python3.9/site-packages/mkdocs_with_confluence/plugin.py", line 45, in on_nav
    p = spaces + self.__get_page_title(n)
  File "/Users/mkj/.pyenv/versions/3.9.7/envs/mkdocs-with-confluence/lib/python3.9/site-packages/mkdocs_with_confluence/plugin.py", line 274, in __get_page_title
    return re.search("\\s*Page\\(title='(.*)',", section).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

mkdocs.yml:

site_name: Publish from MkDocs to Confluence
plugins:
  - search
  - mkdocs-with-confluence:
      host_url: !ENV [HOST, "n/a"]
      space: !ENV [SPACE, "foo"]
      parent_page_name: !ENV [PARENT, "foo"]
      username: !ENV [USER, "foo"]
      password: !ENV [PW, "foo"]
      enabled_if_env: WITH_CONFLUENCE

Environment variables have been tested and work properly (using confluence api directly).

This happend with the following setup:

$ pip list
Package                Version
---------------------- ---------
certifi                2021.10.8
charset-normalizer     2.0.7
click                  8.0.3
colorama               0.4.4
formats                0.1.1
ghp-import             2.0.2
httpretty              1.1.4
idna                   3.3
importlib-metadata     4.8.1
Jinja2                 3.0.2
Markdown               3.3.4
MarkupSafe             2.0.1
md2cf                  1.0.3
mergedeep              1.3.4
mistune                0.8.4
mkdocs                 1.2.3
mkdocs-with-confluence 0.2.2
packaging              21.0
pip                    21.3.1
pyparsing              3.0.1
python-dateutil        2.8.2
PyYAML                 5.3.1
pyyaml_env_tag         0.1
requests               2.26.0
setuptools             57.4.0
six                    1.16.0
tortilla               0.5.0
urllib3                1.26.7
watchdog               2.1.6
zipp                   3.6.0
Dej9132 commented 2 years ago

I encountered the same issue.

Setting up at least one navigation item in the mkdocs.yml file solved the issue.

pawelsikora commented 2 years ago

I encountered the same issue.

Setting up at least one navigation item in the mkdocs.yml file solved the issue.

Thanks @Dej9132 for pointing it out and sorry @jannismain for such a delayed reply.

I tried to fix it with your case when no nav is set but still some .md files are in the directory structure and It worked for me.

The new rel 0.2.5 was pushed on tuesday to pypi and I created pull request #4 into main branch, so if any of you will find a time to check this particular case and comment here or in pull request I would consider to merge it to main branch.

I did released it cause of some other improvements due to the current project I was working on and using this plugin, so in any case something may be working different for you than on previous version - just stick to that one and please let me know in this or open a new issue. I will work more on this plugin this month :)

KR, Pawel