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

Allow mkdocs-gen-files generated content #78

Closed
thejcannon opened this issue Aug 9, 2023 · 4 comments · Fixed by #79
Closed

Allow mkdocs-gen-files generated content #78

thejcannon opened this issue Aug 9, 2023 · 4 comments · Fixed by #79

Comments

@thejcannon
Copy link
Contributor

👋 Loving the plugin!

Currently also loving https://github.com/oprypin/mkdocs-gen-files, but noticed that if I generate navs, or pages referenced by my static navs, they don't end up making it to the generated docsite.

E.g.
mkdocs.yml

plugins:
  - gen-files:
      scripts:
        - generate_reference_docs.py
  - awesome-pages:
      filename: .nav.yaml

generate_reference_docs.py

with mkdocs_gen_files.open(f"reference/global-options.md", "w") as f:
    f.write("Hello world!\n")
with mkdocs_gen_files.open(f"reference/goals/index.md", "w") as f:
    f.write("# Goals!\n")
with mkdocs_gen_files.open(f"reference/goals/.nav.yaml", "w") as f:
    f.write("nav:\n  - index.md\n")

along with:

$ tree -a docs/markdown/reference
docs/markdown/reference
└── .nav.yaml
$ cat docs/markdown/reference/.nav.yaml 
nav:
  - Global Options: global-options.md
  - Goals: goals

Results in Reference being in the nav, but is "flat". No expand arrow.

Additionally, the pages do exist, /reference/global-options is a valid URL and gives what I expect.

@thejcannon
Copy link
Contributor Author

Hmm, so poking around mkdocs and https://github.com/oprypin/mkdocs-gen-files, I suspect that that plugin ought to define on_nav and allow customization. I'll file an issue over there and close one when the other is complete.

@thejcannon
Copy link
Contributor Author

Nevermind, I think I got this working on this plugin, using the Files provided by mkdocs instead of scraping the docs_dir directly.

I'll try and whip up a PR today 😄

@lukasgeiter
Copy link
Owner

Keep in mind that under normal circumstances .nav.yml wouldn't be included in Files.

If I understand mkdocs-gen-files correctly, the files are temporarily created somewhere outside of docs_dir. Maybe you can try to get my plugin to read the .nav.yml file from there.

@thejcannon
Copy link
Contributor Author

OK, today might be a stretch. I got it to respect generated .md files pretty easily.

Generated navs is a bit harder 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants