jdoiro3 / mkdocs-multirepo-plugin

Build documentation in multiple repos into one site.
MIT License
126 stars 47 forks source link

including code from paths outside of the mkdocs directory #42

Open jorgheymans opened 2 years ago

jorgheymans commented 2 years ago

Does the plugin support importing code snippets from other paths ?

We have often things like this in our doc:

--8<-- "../component/src/test/java/mkdocs/Example.java"

When building a multirepo mkdocs site, it fails:

ERROR    -  Error reading page 'example/index.md': Snippet at path
            ../component/src/test/java/mkdocs/Example.java could not be found

I am using nav based multirepo import like this:

Example: '!import git@gitlab-01.mgmt.lan:myrepo.git?extra_imports=["component/*"]'

The imported repo structure is this:

component
  src
    test
      java
mkdocs
  mkdocs.yml
the-real-cphillips commented 2 years ago

@jorgheymans you can try to add an extra_imports parameter to the import url. I had the same issue as you, I was able to handle it with that... this is where I found the idea

https://github.com/jdoiro3/mkdocs-multirepo-plugin/issues/35

jorgheymans commented 2 years ago

Thanks, I have tried the extra_imports as you can see in the example above. But it did not work, my guess is that it's getting confused over the relative path part ../component/ . To elaborate, here is the more detailed structure of the repository that i'm trying to import, as i noticed in above example it's actually not complete

component
  src
    test
      java
mkdocs
  index.md
mkdocs.yml

The index.md contains relative references to ../component/src/test/java. Is there a way to see where and how the imported site is cloned at the moment when mkdocs generates the site?

DavidBuettner commented 2 years ago

@jorgheymans, I have the same problem. I looked through the code for a littlebit and it seems that the main problem is that the imported files are moved to the new include directory (i.e. "one-level-up" via the call to the scrip []mv_docs_up.sh](https://github.com/jdoiro3/mkdocs-multirepo-plugin/blob/main/mkdocs_multirepo_plugin/scripts/mv_docs_up.sh))

This results in the relative links beine messed up.
Additional aspects I saw related to this: The imported mkdocs.yml and other extra_imports are not moved up, but placed into the same directory where the documentation is moved up to.

If you for example have ./docs/index.md include something from ./src/code.cpp you have two options, which both do not solve the problem:

  1. Use extra_imports for the file code.cpp. Then it is - in the end - next to index.md in the folder ./.deps/<section name> and your reference to ../src/code.cpp is broken (now needs to be ./code.cpp , or
  2. Use extra_imports for the folder src. Then the folder is - in the end - next to index.md in the folder ./.deps/<section name> and your reference to ../src/code.cpp is broken as well (now needs to be ./src/code.cpp.

@jdoiro3, is there a reason for moving everything up? I understand that you adjust the nav config in place which could (probably?) work without moving it up? Then the extra imports would leave everything from an imported project in ./.deps/<section_name>/ without changing relative file locations. This again would help with plugins like include-markdown...

Please forgive me if I missed something obvious - I was only able to spend an hour on going through the code to understand what is going on.

Anyway: having it work for includes would be highly useful for us as well...

Cheers, David

(@nejch - FYI)

ssbarnea commented 1 year ago

I guess that nobody was able to make imports work with multirepos... :(

jdoiro3 commented 1 year ago

It might be implemented one day but it's hard to maintain this while also having a full time job. I might get to this one of these days but always open to others opening PRs.

jdoiro3 commented 1 year ago

In v0.5.0 I introduced a new config param (keep_docs_dir) that doesn't delete the docs_dir and doesn't move docs up.

More here: https://github.com/jdoiro3/mkdocs-multirepo-plugin/releases/tag/v0.5.0

jonesbusy commented 7 months ago

Hi,

Was facing the same, when importing site with code snippet outside de docs directory (https://facelessuser.github.io/pymdown-extensions/extensions/snippets/)

I tried extra import but I always end up with wrong link reference. Even by adding base_path of snippet to the mono-repo.

If someone has any idea...

Thanks!