Comments (5)
Done! Will release it soon.
from griffe.
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" %}
.
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.
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.
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.
Sorry that I just woke up due to the time difference
Haha no problem of course 😄
from griffe.
Related Issues (20)
- API checks: Don't report type-guarded objects HOT 4
- API checks: Improve reporting for attribute who lost their value
- Module overrides member HOT 3
- feature: Expressions modernization HOT 1
- not all members have is_package/is_module HOT 3
- class attribute has label 'instance-attribute' HOT 3
- feature: Support meson-python's editable installs
- bug: property and cached_property of dataclasses are class parameters HOT 1
- bug: A dataclass field with init=False should not be a parameter HOT 3
- bug: parameter kinds for dataclasses should match the non-dataclass equivalents
- bug: MkDocs !!! and ??? admonitions can no longer be parsed HOT 3
- bug: Regular classes that inherit dataclass do not get dataclass parameters HOT 1
- bug: A class that derives from a dataclass should be labelled a dataclass HOT 2
- feature: Merge value when attribute is first annotated then assigned
- docs: bad link HOT 2
- feature: Future backward-compatibility warnings
- feature: API checks: diff each sequence/mapping value instead of the whole
- bug: Error reading page: tuple index out of range HOT 3
- feature: API checks: Report new positional-or-keyword parameters inserted before other positional-or-keyword parameters
- feature: Warning/hint for objects coming from siblings/parents/external exposed in __all__
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from griffe.