Skip to content

Commit

Permalink
fix: tooltips for class docstrings, whitespace issues
Browse files Browse the repository at this point in the history
- fixes linebreaks between text and HTML tags caused by templatetag
- checks for existence of docstrings following Python formatting
  conventions (see PEP 257) instead of falling back on class definition

PEP 257: https://peps.python.org/pep-0257/
  • Loading branch information
koeaw committed Dec 7, 2023
1 parent 5b2bfd6 commit 8731b3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions apis_core/apis_entities/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ def get_context_data(self, **kwargs):
context[self.context_filter_name] = self.filter
context["entity"] = self.entity # model slug
context["app_name"] = "apis_entities"
context["docstring"] = f"{model.__doc__}"

context["entity_create_stanbol"] = GenericEntitiesStanbolForm(self.entity)

# only consider properly formatted docstrings (PEP 257)
if '"""' in model.__doc__:
context["docstring"] = f"{model.__doc__}"

if "browsing" in settings.INSTALLED_APPS:
from browsing.models import BrowsConf

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<abbr title="{{ docstring }}">{{ class_name }}</abbr>
{% if docstring %}
<abbr title="{{ docstring }}">{{ class_name }}</abbr>
{% else %}
{{ class_name }}
{% endif %}
2 changes: 1 addition & 1 deletion apis_core/apis_metainfo/templates/generic_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="card-header">
<div class="row">
<div class="col-sm">
<h2 class="mb-0">
<h2 class="mb-0" style="white-space: nowrap;">
Browse {% class_definition %}

{% block list_title %}{% endblock %}
Expand Down

0 comments on commit 8731b3b

Please sign in to comment.