diff --git a/src/mkdocstrings/templates/python/material/_base/class.html b/src/mkdocstrings/templates/python/material/_base/class.html index 6f5e4a2b..37724e17 100644 --- a/src/mkdocstrings/templates/python/material/_base/class.html +++ b/src/mkdocstrings/templates/python/material/_base/class.html @@ -54,7 +54,7 @@ {% include "docstring.html" with context %} {% endwith %} - {% if config.show_source %} + {% if config.show_source and class.source %}
Source code in {{ class.relative_filepath }} {{ class.source|highlight(language="python", linestart=class.lineno, linenums=True) }} diff --git a/src/mkdocstrings/templates/python/material/_base/function.html b/src/mkdocstrings/templates/python/material/_base/function.html index 928ac7d4..8538447f 100644 --- a/src/mkdocstrings/templates/python/material/_base/function.html +++ b/src/mkdocstrings/templates/python/material/_base/function.html @@ -62,7 +62,7 @@ {% include "docstring.html" with context %} {% endwith %} - {% if config.show_source %} + {% if config.show_source and function.source %}
Source code in {{ function.relative_filepath }} {{ function.source|highlight(language="python", linestart=function.lineno, linenums=True) }}