Git Product home page Git Product logo

Comments (4)

apiad avatar apiad commented on September 28, 2024 1

Ahh you still have to write the link as module.md#class:ClassName, instead of module::ClassName. Getting there requires a little bit of parsing of the Markdown content itself, which right now we just output verbatim. It is on the roadmap, though.

from illiterate.

apiad avatar apiad commented on September 28, 2024 1

I think is ready now. You can reference any top-level type or method with ref:module.name and it will be automatically converted to the right path.

from illiterate.

apiad avatar apiad commented on September 28, 2024

Yeah, I love that! It is definitely something I want to have. I think this would require automatically inserting some <a/> tags for every class (and method?) in the markdown. In any case, this will require a little bit more "parsing" of the Python source, maybe it's OK for an MVP to just check for a r"class (.+):\n" line instead of actually lifting the AST, but in the long run probably a full parsing of the code will be useful for a lot of these kind of tweaks.

from illiterate.

apiad avatar apiad commented on September 28, 2024

So, I tried parsing the code with Python ast module. That's a definite no-no because first, it will drop comments (obviously 🤦 ) and second we have no way to ensure we can dump the exact same code layout. So I kind of solved this with regexes by looking for class and def top-level definitions.

Now we output anchors for each of these, right before the Python block where they are defined. The bad news is that if you have more than one in the same Python block, all their anchors will point to the same block, not to individual lines inside the block because there is no easy way to inject HTML inside Markdown code blocks. But at least is something.

from illiterate.

Related Issues (5)

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.