Opened 3 weeks ago

Closed 11 days ago

#35867 closed Bug (fixed)

admindocs links are not generated on Views documentation

Reported by: Lucas Brandstätter Owned by: SAI GANESH S
Component: contrib.admindocs Version: 5.1
Severity: Normal Keywords: admindocs
Cc: Lucas Brandstätter, SAI GANESH S Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When I use the admindocs app to generate a documentation on a view the special markup such as

class MyModelFormView(FormView)
"""
This is a form view for :model:`core.Model`
"""

do not generate any links to the core.Model documentation.

When I use the same markup in a model docstring they work as expected an generate a link to the corresponding model.

Change History (8)

comment:1 by Lucas Brandstätter, 3 weeks ago

Just realized that this only applies to the first line of the docstring

"""
This is a form view for :model:`core.Model` <- Does not generate a link

In this view a :model:`core.Model` is modified <- Generates a link
"""
Last edited 3 weeks ago by Lucas Brandstätter (previous) (diff)

comment:2 by Sarah Boyce, 3 weeks ago

Triage Stage: UnreviewedAccepted

Thank you for the report!
Replicated, here is an example testcase:

  • tests/admin_docs/test_views.py

    a b class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):  
    8989        # View docstring
    9090        self.assertContains(response, "Base view for admindocs views.")
    9191
     92    def testview_docstring_links(self):
     93        summary = (
     94            '<h2 class="subhead"><p>This is a view for '
     95            '<a class="reference external" href="/admindocs/models/myapp.company/">'
     96            "myapp.Company</a></p></h2>"
     97        )
     98        url = reverse(
     99            "django-admindocs-views-detail", args=["admin_docs.views.CompanyView"]
     100        )
     101        response = self.client.get(url)
     102        self.assertContains(response, summary, html=True)
     103
    92104    @override_settings(ROOT_URLCONF="admin_docs.namespace_urls")
    93105    def test_namespaced_view_detail(self):
    94106        url = reverse(
  • tests/admin_docs/urls.py

    diff --git a/tests/admin_docs/urls.py b/tests/admin_docs/urls.py
    index de23d9baf5..779d5f9f5f 100644
    a b urlpatterns = [  
    1414    path("admin/", admin.site.urls),
    1515    path("admindocs/", include("django.contrib.admindocs.urls")),
    1616    path("", include(ns_patterns, namespace="test")),
     17    path("company/", views.CompanyView.as_view()),
    1718    path("xview/func/", views.xview_dec(views.xview)),
    1819    path("xview/class/", views.xview_dec(views.XViewClass.as_view())),
    1920    path("xview/callable_object/", views.xview_dec(views.XViewCallableObject())),
  • tests/admin_docs/views.py

    diff --git a/tests/admin_docs/views.py b/tests/admin_docs/views.py
    index 21fe382bba..5bccaf29a0 100644
    a b class XViewClass(View):  
    1818class XViewCallableObject(View):
    1919    def __call__(self, request):
    2020        return HttpResponse()
     21
     22
     23class CompanyView(View):
     24    """
     25    This is a view for :model:`myapp.Company`
     26    """
     27
     28    def get(self, request):
     29        return HttpResponse()

There is already a ticket for some issues of links in docstrings #27409. I will accept but this might be combined with 27409 in future.

comment:3 by SAI GANESH S, 2 weeks ago

Cc: SAI GANESH S added
Owner: set to SAI GANESH S
Status: newassigned

comment:4 by SAI GANESH S, 2 weeks ago

Has patch: set

comment:5 by Sarah Boyce, 2 weeks ago

Triage Stage: AcceptedReady for checkin

comment:6 by Sarah Boyce, 2 weeks ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

comment:7 by Sarah Boyce, 11 days ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:8 by Sarah Boyce <42296566+sarahboyce@…>, 11 days ago

Resolution: fixed
Status: assignedclosed

In 96839722:

Fixed #35867, Refs #2411 -- Allowed links in admindocs view details summary.

Note: See TracTickets for help on using tickets.
Back to Top