Skip to content

Commit

Permalink
fix: tooltips for class docstrings, whitespace issues
Browse files Browse the repository at this point in the history
- fixes occasional linebreaks between regular text and <abbr> HTML
  tags for tooltips with class meta information
- checks for existence of actual docstrings for classes to display
  on frontend over defaulting to class definitions "Class(a, b)"
  • Loading branch information
koeaw committed Dec 11, 2023
1 parent 5b2bfd6 commit 6471227
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions apis_core/apis_entities/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,16 @@ 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)

# model.__doc__ defaults to "ClassName(attr1, attr2)" when there is no
# actual docstring, which is not helpful to output on the frontend
if (
f"{model.__doc__}"
!= f"{model.__name__}({', '.join([f.name for f in model._meta.fields])})"
):
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 6471227

Please sign in to comment.