Code Monkey home page Code Monkey logo

Comments (5)

pawamoy avatar pawamoy commented on July 22, 2024 1

Done! Will release it soon.

from griffe.

wxdrizzle avatar wxdrizzle commented on July 22, 2024

I solved this issue by changing {% if section_type == "markdown" %} to {% if section_type|string == "DocstringSectionKind.text" %}, and also changing {% if section_type == "examples" %} to {% if section_type|string == "DocstringSectionKind.examples" %}.

Now it looks like:
image

So for the developer: I think the corresponding code in the template of examples need to be modified in such way. Could you please confirm this?

How I got the solution:
After I found {{ section_type == "DocstringSectionKind.examples"}} is still False, I think although the type of section_type is indeed DocstringSectionKind.examples, but it is not equal to a string "DocstringSectionKind.examples". So I managed to change section_type to a string type. I tried str(section_type) but got an error when running mkdocs, from which I got to know that the language (?) is called "jinja2", so I searched "jinja2 how to convert variable to string", and found the answer is section_type|string. Finally I came up with the solution.

from griffe.

pawamoy avatar pawamoy commented on July 22, 2024

Hi again @wxdrizzle! Thanks for the detailed bug report, and the solution to the issue 😄
Indeed, I forgot to update this template: we now use enums and can't compare them directly to strings.
And markdown was changed to text.

So the final fix will look like this:

{% for section_type, sub_section in section.value %}
  {% if section_type.value == "text" %}
    {{ sub_section|convert_markdown(heading_level, html_id) }}
  {% elif section_type.value == "examples" %}
    {{ sub_section|highlight(language="python", linenums=False) }}
  {% endif %}
{% endfor %}

Do you want to send a PR (on the mkdocstrings/python repo) with that 🙂? If not, I'll do it in the afternoon anyway!

from griffe.

wxdrizzle avatar wxdrizzle commented on July 22, 2024

Great work! Sorry that I just woke up due to the time difference. Thank you for the quick reply and quick fix @pawamoy 😄

from griffe.

pawamoy avatar pawamoy commented on July 22, 2024

Sorry that I just woke up due to the time difference

Haha no problem of course 😄

from griffe.

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.