Skip to content

Commit c5463e6

Browse files
committed
- Move create content before get content.
- Align code example with actual code. - Add type hint to build_plone_client_command function. - Add ability to download a complete example.
1 parent bd1a234 commit c5463e6

3 files changed

Lines changed: 30 additions & 25 deletions

File tree

docs/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@
8989
# Add any paths that contain custom static files (such as style sheets) here,
9090
# relative to this directory. They are copied after the builtin static files,
9191
# so a file named "default.css" will overwrite the builtin "default.css".
92-
html_static_path = ["_static"]
92+
html_static_path = [
93+
"_static",
94+
"plone_client.py",
95+
]
9396

9497
# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-smartquotes_action
9598
smartquotes_action = "De"

docs/custom.rst

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Custom builder
44

55
Some packages use an API to send HTTP requests.
66
This allows developers to focus on API calls instead of forming HTTP requests with low level utilities.
7-
For such packages, ``sphinxcontrib.httpexample`` supports custom builders.
7+
For such packages, sphinxcontrib.httpexample supports custom builders.
88

99
The examples in this chapter use the `@plone/client <https://www.npmjs.com/package/@plone/client>`_ package, an agnostic library that provides easy access to the Plone REST API from a client written in TypeScript.
1010

@@ -18,10 +18,10 @@ In this file, define a custom method as your builder.
1818

1919
.. code:: python
2020
21-
def build_plone_client_command(request: HTTPRequest): str
22-
result = ""
21+
def build_plone_client_command(request: HTTPRequest) -> str:
22+
output = ""
2323
# ...
24-
return result
24+
return output
2525
2626
Next, in :file:`docs/conf.py`, register the builder with ``register_builder()`` to make it available.
2727

@@ -55,6 +55,27 @@ The ``register_builder`` method has the following parameters.
5555
``label``
5656
The display name of the tab in the documentation.
5757

58+
For a complete example, download :download:`plone_client.py`.
59+
60+
61+
Create content
62+
==============
63+
64+
The following example creates content at the specified path with the given JSON body.
65+
66+
.. http:example:: curl plone-client
67+
68+
POST /Plone/folder HTTP/1.1
69+
Host: localhost:8080
70+
Content-Type: application/json
71+
Accept: application/json
72+
Authorization: Basic YWRtaW46YWRtaW4=
73+
74+
{
75+
"@type": "Document",
76+
"title": "My New Document"
77+
}
78+
5879

5980
Get content
6081
===========
@@ -93,22 +114,3 @@ The following example updates the content at the specified location.
93114
{
94115
"title": "My New Document Title"
95116
}
96-
97-
98-
Create content
99-
==============
100-
101-
The following example creates content at the specified path with the given JSON body.
102-
103-
.. http:example:: curl plone-client
104-
105-
POST /Plone/folder HTTP/1.1
106-
Host: localhost:8080
107-
Content-Type: application/json
108-
Accept: application/json
109-
Authorization: Basic YWRtaW46YWRtaW4=
110-
111-
{
112-
"@type": "Document",
113-
"title": "My New Document"
114-
}

docs/plone_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def post_content(request: HTTPRequest):
8282
"""
8383

8484

85-
def build_plone_client_command(request: HTTPRequest):
85+
def build_plone_client_command(request: HTTPRequest) -> str:
8686
url = urlparse(request.url())
8787
portal_path = url.path.split("/")[1]
8888
output = f"""\

0 commit comments

Comments
 (0)