Merge ~adam-collard/maas:api-docs-reformat into maas:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: a73860a5e37ea1cb4ff4c559889d79a9d3380307
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas:api-docs-reformat
Merge into: maas:master
Prerequisite: ~adam-collard/maas:api-docs-cleanup
Diff against target: 82 lines (+18/-8)
3 files modified
src/maasserver/api/doc_handler.py (+16/-4)
src/maasserver/api/tmpl-apidoc.rst (+1/-3)
src/maasserver/tests/test_commands.py (+1/-1)
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
MAAS Lander unittests Pending
Review via email: mp+397231@code.launchpad.net

Commit message

Remove unwanted formatting of docs

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/doc_handler.py b/src/maasserver/api/doc_handler.py
2index 6652133..6425110 100644
3--- a/src/maasserver/api/doc_handler.py
4+++ b/src/maasserver/api/doc_handler.py
5@@ -81,7 +81,7 @@ from maasserver.utils import build_absolute_uri
6 api_doc_title = dedent(
7 """
8 :tocdepth: 3
9- .. _region-controller-api:
10+ .. _maas-api:
11
12 ========
13 MAAS API
14@@ -168,7 +168,9 @@ def render_api_docs():
15 line()
16 for (http_method, op), function in sorted(exports, key=export_key):
17 operation = " op=%s" % op if op is not None else ""
18- subsection = "``%s %s%s``" % (http_method, uri_template, operation)
19+ subsection = (
20+ f"<code>{http_method} {uri_template}{operation}</code>"
21+ )
22 docstring = getdoc(function)
23 if docstring is not None:
24 if APIDocstringParser.is_annotated_docstring(docstring):
25@@ -183,7 +185,10 @@ def render_api_docs():
26 )
27 )
28 else:
29- line("%s\n%s\n" % (subsection, "#" * len(subsection)))
30+ line(".. raw:: html")
31+ line()
32+ line(" <details>")
33+ line(f" <summary>{subsection}</summary>")
34 line()
35 for docline in dedent(docstring).splitlines():
36 if docline.strip() == "":
37@@ -192,9 +197,16 @@ def render_api_docs():
38 else:
39 # Print documentation line, indented.
40 line(docline)
41+ line()
42+ line(".. raw:: html")
43+ line()
44+ line(" </details>")
45+ line()
46 line()
47 else:
48- line("%s\n%s\n" % (subsection, "#" * len(subsection)))
49+ line(".. raw:: html")
50+ line()
51+ line(f" <p>{subsection}</p>\n")
52 line()
53
54 line()
55diff --git a/src/maasserver/api/tmpl-apidoc.rst b/src/maasserver/api/tmpl-apidoc.rst
56index af49b2b..1d2c3e5 100644
57--- a/src/maasserver/api/tmpl-apidoc.rst
58+++ b/src/maasserver/api/tmpl-apidoc.rst
59@@ -1,9 +1,7 @@
60 .. raw:: html
61
62 <details>
63- <summary>``{{ http_method }} {{ uri }}{{if operation != ""}}?{{ operation }}{{endif}}``</summary>
64-
65-######################################################################################################
66+ <summary><code>{{ http_method }} {{ uri }}{{if operation != ""}}?{{ operation }}{{endif}}</code></summary>
67
68 {{py:
69 params_length = len(params)
70diff --git a/src/maasserver/tests/test_commands.py b/src/maasserver/tests/test_commands.py
71index fdda41e..ce906c9 100644
72--- a/src/maasserver/tests/test_commands.py
73+++ b/src/maasserver/tests/test_commands.py
74@@ -62,7 +62,7 @@ class TestCommands(MAASServerTestCase):
75 # should not exceed 3 levels deep.)
76 self.assertThat(
77 result[:100],
78- StartsWith(":tocdepth: 3\n.. _region-controller-api:"),
79+ StartsWith(":tocdepth: 3\n.. _maas-api:"),
80 )
81 # It also contains a ReST title (not indented).
82 self.assertIn("===", result[:100])

Subscribers

People subscribed via source and target branches