machow / ibis-docs-demo

0 stars 0 forks source link

How to embed rendered docstrings within other doc pages? #3

Open machow opened 1 year ago

machow commented 1 year ago

On ibis backend pages, the docstring for the backend's connect() method is rendered onto the page. For example, here's the docstring for clickhouse's connect method.

image

Let's double check the right way to do this. I'm guessing it's the way documented on https://machow.github.io/quartodoc/get-started/dev-big-picture.html:

from quartodoc import Builder, Auto, blueprint

builder = Builder.from_quarto_config("_quarto.yml")

obj = blueprint(Auto(name = "quartodoc.MdRenderer.render"))
builder.renderer.render(obj)

This should be roughly equivalent to putting it in _quarto.yml (including generating a section for the object).

Or, a dumber way to just render a docstring:

from quartodoc import MdRenderer, get_object

obj = get_object("quartodoc.MdRenderer.render")
MdRenderer().render(obj)

Longer term option: nbquarto?

The reason we have to include these code blocks, is that quarto extensions can't really be python code (they're written in lua). If we use something like nbquarto, which basically changes how qmds are executed, then we could add directives that trigger python code!

https://github.com/muellerzr/nbquarto