GithubHelp home page GithubHelp logo

Allow multiple hook files about mkdocs HOT 4 OPEN

ofek avatar ofek commented on May 23, 2024
Allow multiple hook files

from mkdocs.

Comments (4)

oprypin avatar oprypin commented on May 23, 2024

There are many options for this:

  • Just do the 2 actions in 1 function

  • Use multiple files (wait, are you saying that multiple hooks files have a problem?)

  • Use this upcoming feature, though I should double-check whether it actually works for hooks
    #3448

Or actually I know what it is - it's about on_page_read_source specifically. I think this event type is fundamentally broken, actually? The definition is "replace the default mechanism to read the contents of a page's source from the filesystem" - so yeah if you replace the mechanism once and read the original source file, and then replace the mechanism another time and read the original source file, that's exactly what will happen?

I was just looking through your hooks yesterday and saw that your usage would be much simpler served by on_page_markdown, that's definitely what you should switch to at the moment, and it would not have this problem at all.

from mkdocs.

ofek avatar ofek commented on May 23, 2024

Oh okay, that makes sense that I was using the wrong plugin type. My bad! Before I close this can you take a look at the PR that I merged to fix this? It works fine but I'm wondering what you think.

from mkdocs.

oprypin avatar oprypin commented on May 23, 2024

The actionable thing for me is one of these:

  • Deprecate on_page_read_source event type because I think there are better alternatives to it in every case

  • Show an error if multiple handlers for it are added (it's the only event type that is incompatible with having multiple handlers)

So it's helpful that you brought this up

from mkdocs.

oprypin avatar oprypin commented on May 23, 2024

look at the PR that I merged to fix this

Commented there-
yeah you can revert pypa/hatch#1065 and, in the previous state of the code, change each on_page_read_source to on_page_markdown and it's the same except you get the source directly instead of messing with abs_src_path. And, well, it will actually work

from mkdocs.

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.