0

i was following the Tutorial for the “recipe” extension (https://www.sphinx-doc.org/en/master/development/tutorials/recipe.html).

I am a little confused as the compiled html side doesn't show the ingredients defined in the contains option. Does anyone has an idea what I might have missed from the docs?

Is there any way using sphinx to show the data e.g. self.data["recipe_ingredients"][name] or print the list of the IngredientIndies from RecipeDomain.indices?

I added my code to: https://github.com/jonassorgenfrei/LUMACH-SphinxDemo

And was expecting that the recipe section shows the ingredients: https://jonassorgenfrei.github.io/LUMACH-SphinxDemo/recipes.html

mzjn
  • 48,958
  • 13
  • 128
  • 248
  • 1
    It is not clear to me what to expect from the recipe extension. There is one bug reported on the tutorial: https://github.com/sphinx-doc/sphinx/issues/6983 – mzjn Dec 29 '22 at 11:35
  • 1
    Two special index pages are generated: https://jonassorgenfrei.github.io/LUMACH-SphinxDemo/recipe-ingredient.html and https://jonassorgenfrei.github.io/LUMACH-SphinxDemo/recipe-recipe.html – mzjn Dec 29 '22 at 12:25
  • 1
    The tutorial was updated just now: https://github.com/sphinx-doc/sphinx/commit/32bce8fb7c0b7a2eb89c7e0e3e7ef13fce7f03a6 – mzjn Dec 29 '22 at 14:02
  • Thank you @mzjn the the reference to the index already helped a lot, i actually missed the part of the index page creation, but your clarification helped a lot. But I'm still curious what i would have to change to actually display the ingredients below the on the page tomato-soup.html(in my case: https://jonassorgenfrei.github.io/LUMACH-SphinxDemo/recipes.html). – Jonas Sorgenfrei Dec 30 '22 at 00:20

1 Answers1

0

I think i found what i was looking for, i implemented the transform_content method for class RecipeDirective(ObjectDescription) and was able to add the Ingredient information in this step to the content:

def transform_content(self, contentnode: addnodes.desc_content) -> None:
    if "contains" in self.options:
        paragraph_node = nodes.paragraph(text="Ingredients: {}".format(self.options.get("contains")))
        contentnode.insert(0, paragraph_node)

But not sure if this is the best approach.