Code Monkey home page Code Monkey logo

Comments (7)

Andre601 avatar Andre601 commented on June 7, 2024

Actually, it seems that this also causes an issue with linking, because the link [bot](bot.md) leads to a 404 page on the built docs, because MkDocs isn't parsing the link into the actual page.

Like, I have the following file structure:

docs/
├── de-CH/
│   └── legal/
│       └── index.md
└── en/
    └── legal/
        ├── bot.md
        └── index.md

With index.md having a link to bot.md in both folders.
For the default language (English) does this work fine, but for de-CH does it give a 404 because it doesn't have a bot.md file present and MkDocs treats it as a broken link, not parsing it...

Can this be fixed?

from mkdocs-static-i18n.

kamilkrzyskow avatar kamilkrzyskow commented on June 7, 2024

Weird, I have a lot of untranslated pages and don't have this error.

But from your docs tree example I see you're using the folder structure instead of suffix like I do.

Perhaps the bug is somewhere there in the folder structure logic. I will try to reproduce it based on the example.

from mkdocs-static-i18n.

Andre601 avatar Andre601 commented on June 7, 2024

The actual docs source can be found here: https://github.com/purrbot-site/Docs

from mkdocs-static-i18n.

kamilkrzyskow avatar kamilkrzyskow commented on June 7, 2024

I did some debugging and it turned out there are actually two bugs in the folder file lookup:
Here is a console output of some print statements:

looked up target -> de-CH/credits/index.md
variant=credits/index.md file=None
variant=en/de-CH/credits/index.md file=None
variant=de-CH/credits/index.md file=File(src_uri='de-CH/credits/index.md', dest_uri='de-CH/credits/index.html', name='index', url='de-CH/credits/')
---
looked up target -> de-CH/legal/bot.md
variant=legal/bot.md file=None
variant=en/de-CH/legal/bot.md file=None
variant=de-CH/legal/bot.md file=None
WARNING -  Doc file 'de-CH/legal/index.md' contains a relative link 'bot.md', but the target 'de-CH/legal/bot.md' is not found among documentation
           files.
---
looked up target -> de-CH/legal/api.md
variant=legal/api.md file=None
variant=en/de-CH/legal/api.md file=None
variant=de-CH/legal/api.md file=None
WARNING -  Doc file 'de-CH/legal/index.md' contains a relative link 'api.md', but the target 'de-CH/legal/api.md' is not found among documentation
           files.

Taking the issue from the OP, the de-CH/legal/bot.md file lookup searches for en/de-CH/legal/api.md instead of en/legal/api.md and therefore it can't find such file.

As for the second bug, it's in the lookup order of the variants. For example if we'd fix the first issue, for de-CH/credits/index.md it would lookup en/credits/index.md before finding de-CH/credits/index.md.

from mkdocs-static-i18n.

Andre601 avatar Andre601 commented on June 7, 2024

Not sure if this is the right logic you have there...

I have en set as default, so the effective path for the link should be equivalent to api.md as an example.

Tho, Ialso may misunderstand stuff...

from mkdocs-static-i18n.

kamilkrzyskow avatar kamilkrzyskow commented on June 7, 2024

Maybe I missed something when testing, as I was mostly focused on fixing the broken path and warning.
Then found the wrong order of alternative path lookup.

You can clone the branch from the PR and make a more thorough review to make sure nothing else was broken in the process.

from mkdocs-static-i18n.

Andre601 avatar Andre601 commented on June 7, 2024

Maybe I missed something when testing, as I was mostly focused on fixing the broken path and warning. Then found the wrong order of alternative path lookup.

You can clone the branch from the PR and make a more thorough review to make sure nothing else was broken in the process.

Yeah. I'll try to install it with pip and see if there's anything... Will report it in the PR in such a case.

from mkdocs-static-i18n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.