Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lbry
lbrycrd
Commits
ed58f321
Commit
ed58f321
authored
Feb 12, 2019
by
Brannon King
Browse files
move examples to separate section of api doc
parent
62313149
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
contrib/devtools/generate_json_api_v1.py
View file @
ed58f321
...
...
@@ -50,6 +50,29 @@ def parse_params(args):
return
arguments
def
process_examples
(
examples
:
str
):
if
not
examples
:
return
[]
examples
=
examples
.
strip
()
splits
=
examples
.
split
(
'
\n
'
)
result
=
[]
inner
=
{}
for
s
in
splits
:
if
not
s
:
continue
if
'> curl'
in
s
:
inner
[
'curl'
]
=
s
.
strip
()
elif
'> lbrycrd'
in
s
:
inner
[
'cli'
]
=
s
.
strip
()
else
:
if
'title'
in
inner
:
result
.
append
(
inner
)
inner
=
{}
inner
[
'title'
]
=
s
.
strip
()
result
.
append
(
inner
)
return
result
def
get_api
(
section_name
,
command
,
command_help
):
parsed
=
re_full
.
fullmatch
(
command_help
)
...
...
@@ -61,8 +84,7 @@ def get_api(section_name, command, command_help):
arguments
=
parse_params
(
args
)
cmd_desc
=
re
.
sub
(
'\s+'
,
' '
,
desc
.
strip
())
if
desc
else
''
if
exmp
and
'--skip_examples'
not
in
sys
.
argv
:
cmd_desc
+=
'
\n
Examples:
\n
'
+
exmp
.
strip
()
examp_desc
=
process_examples
(
exmp
)
cmd_resl
=
resl
.
strip
()
if
resl
else
None
ret
=
{
...
...
@@ -70,6 +92,7 @@ def get_api(section_name, command, command_help):
'namespace'
:
section_name
,
'description'
:
cmd_desc
,
'arguments'
:
arguments
,
'examples'
:
examp_desc
}
if
cmd_resl
is
not
None
:
ret
[
'returns'
]
=
cmd_resl
...
...
contrib/devtools/generated/api_v1.json
View file @
ed58f321
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment