Skip to content

Commit

Permalink
manage.py (pre-commit): Improve clarity of paths_to_skip logic
Browse files Browse the repository at this point in the history
  • Loading branch information
duncandewhurst committed Nov 13, 2023
1 parent 29cb3e0 commit 8e0209c
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,23 +343,16 @@ def update_sub_schema_reference(schema):
# Add examples
definition["references"] = get_definition_references(schema, defn)
for ref in definition["references"]:
if ref[0] not in schema['definitions']:
skip = False

for path_to_skip in paths_to_skip:
if path_to_skip == '/'.join(ref)[:len(path_to_skip)]:
skip = True

if not skip:
if ref[-1] == '0':
ref.pop(-1)

definition["content"].extend([
"```{jsoninclude} ../../docs/examples/example.json\n",
f":jsonpointer: /projects/0/{'/'.join(ref)}\n",
f":title: {'/'.join(ref)}\n",
"```\n\n"
])
if ref[0] not in schema['definitions'] and not any(p == '/'.join(ref)[:len(p)] for p in paths_to_skip):
if ref[-1] == '0':
ref.pop(-1)

definition["content"].extend([
"```{jsoninclude} ../../docs/examples/example.json\n",
f":jsonpointer: /projects/0/{'/'.join(ref)}\n",
f":title: {'/'.join(ref)}\n",
"```\n\n"
])

definition["content"].extend([
"````\n\n",
Expand Down

0 comments on commit 8e0209c

Please sign in to comment.