ovasquez / mkdocs-merge

Merge the source of multiple MkDocs sites into a single one
https://ovasquez.github.io/mkdocs-merge/
MIT License
22 stars 6 forks source link

remove nav entry and make it optional as it is not required #14

Open hsjobeki opened 2 years ago

hsjobeki commented 2 years ago

Hey Oscar,

I just found your tool, as it is currently the only one I found so far for combining many docs into a single source. Still, you built a pretty awesome base that could be extended further. ;)

I found, that providing the "nav" entry in mkdocs.yaml is pretty useless as mkdocs will discover all the files by itself. I am a little new to this topic. but am I wrong?

hsjobeki commented 2 years ago

I'd like to suggest some more improvements from my side, that I will pretty likely make in a fork of your code.

  1. Don't overwrite the Master, put the output in a new directory. People might want to re-run your tool. -> eg.g build/ should be re-created on each run.
  2. If you have multiple documentations and merge them into one, you might also have different git URLs in their yaml files. How do you plan to handle that?
ovasquez commented 2 years ago

Hey @hsjobeki, thanks for the suggestions, it's been quite a while since I updated this script but your suggestions make sense. I'll add them as enhancement requests. I don't have a specific timeline for the updates, but I expect to make progress on this during the next month 😊

comatory commented 2 months ago

I would love to have this. For me it even fails on missing nav key which IMHO is not required (I use mkdocs-material).

I would also like have support for build directory, like build/, maybe via site_url configuration?

ovasquez commented 2 months ago

@comatory I know this has been requested for a long time, I'm planning on investing a little bit of time into this code again. Could you provide more details about the missing nav issue? If you could provide a test site or a sample mkdocs.yml with your problem and the expected outcome that would be very helpful, because I could use that as the base requirement.

comatory commented 2 weeks ago

It fails when trying to process multiple documentations:

Could not find the "nav" entry in the yaml file: "/Users/user/Projects/pb-backend/mkdocs.yml", this site will be skipped.
Traceback (most recent call last):
  File "/Users/user/Projects/pb-techdocs/venv/bin/mkdocs-merge", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/user/Projects/pb-techdocs/venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/Projects/pb-techdocs/venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/user/Projects/pb-techdocs/venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/Projects/pb-techdocs/venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/Projects/pb-techdocs/venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/Projects/pb-techdocs/venv/lib/python3.12/site-packages/mkdocsmerge/__main__.py", line 44, in run
    merge.run_merge(master_site, sites, unify_sites, print_func=click.echo)
  File "/Users/user/Projects/pb-techdocs/venv/lib/python3.12/site-packages/mkdocsmerge/merge.py", line 34, in run_merge
    new_navs = merge_sites(sites, master_docs_root, unify_sites, print_func)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/Projects/pb-techdocs/venv/lib/python3.12/site-packages/mkdocsmerge/merge.py", line 112, in merge_sites
    update_navs(site_data[CONFIG_NAVIGATION], site_root, print_func=print_func)
                ~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'nav'

Once I add nav: to mkdocs.yml it starts to work.