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:2 by , 3 weeks ago
Triage Stage: | Unreviewed → Accepted |
---|
Thank you for the report!
Replicated, here is an example testcase:
-
tests/admin_docs/test_views.py
a b class AdminDocViewTests(TestDataMixin, AdminDocsTestCase): 89 89 # View docstring 90 90 self.assertContains(response, "Base view for admindocs views.") 91 91 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 92 104 @override_settings(ROOT_URLCONF="admin_docs.namespace_urls") 93 105 def test_namespaced_view_detail(self): 94 106 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 = [ 14 14 path("admin/", admin.site.urls), 15 15 path("admindocs/", include("django.contrib.admindocs.urls")), 16 16 path("", include(ns_patterns, namespace="test")), 17 path("company/", views.CompanyView.as_view()), 17 18 path("xview/func/", views.xview_dec(views.xview)), 18 19 path("xview/class/", views.xview_dec(views.XViewClass.as_view())), 19 20 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): 18 18 class XViewCallableObject(View): 19 19 def __call__(self, request): 20 20 return HttpResponse() 21 22 23 class 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 , 2 weeks ago
Cc: | added |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:5 by , 2 weeks ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:6 by , 2 weeks ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
comment:7 by , 11 days ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Note:
See TracTickets
for help on using tickets.
Just realized that this only applies to the first line of the docstring