Skip to content

Commit 5ca24e3

Browse files
Fix example generation (#2449) (#2452)
(cherry picked from commit b0e320b) Co-authored-by: Quentin Pradet <[email protected]>
1 parent 2b86966 commit 5ca24e3

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// search/search.asciidoc:10
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
index="my-index-000001",
7+
)
8+
print(resp)
9+
----
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// search/search.asciidoc:945
2+
3+
[source, python]
4+
----
5+
resp = client.search(
6+
index="my-index-000001",
7+
from_="40",
8+
size="20",
9+
body={"query": {"term": {"user.id": "kimchy"}}},
10+
)
11+
print(resp)
12+
----

utils/generate-examples.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"docs/index_.asciidoc",
5353
"aggregations/bucket/terms-aggregation.asciidoc",
5454
"query-dsl/range-query.asciidoc",
55-
"/search/search.asciidoc",
55+
"search/search.asciidoc",
5656
"query-dsl/multi-match-query.asciidoc",
5757
"docs/bulk.asciidoc",
5858
"indices/delete-index.asciidoc",
@@ -158,7 +158,12 @@ def main():
158158
with tempfile.NamedTemporaryFile("w+", delete=False) as tmp_file:
159159
tmp_file.write(t.render(parsed_sources=parsed_sources))
160160

161-
blacken(tmp_file.name)
161+
try:
162+
blacken(tmp_file.name)
163+
except AssertionError:
164+
loc = exm["source_location"]
165+
print(f"Failed to format {loc['file']}:{loc['line']}, skipping.")
166+
continue
162167

163168
with open(tmp_file.name) as f:
164169
data = f.read()

0 commit comments

Comments
 (0)