From c270d68c9e17204606ae12a2159c04563a18ec2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= <pawamoy@pm.me> Date: Sun, 28 Nov 2021 20:19:33 +0100 Subject: [PATCH] fix: Only show source when present --- src/mkdocstrings/templates/python/material/_base/class.html | 2 +- src/mkdocstrings/templates/python/material/_base/function.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 %} <details class="quote"> <summary>Source code in <code>{{ class.relative_filepath }}</code></summary> {{ 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 %} <details class="quote"> <summary>Source code in <code>{{ function.relative_filepath }}</code></summary> {{ function.source|highlight(language="python", linestart=function.lineno, linenums=True) }}