Skip to content

Commit 8059197

Browse files
committed
[#1240] Fixed template/README
1 parent 5221c89 commit 8059197

File tree

7 files changed

+42
-190
lines changed

7 files changed

+42
-190
lines changed

ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1801. [doc] fdupont
2+
Moved JSON files describing commands to the share directory
3+
and adding a new access entry taking read or write values.
4+
(Gitlab #1240)
5+
16
1800. [func] fdupont
27
Added support of basic HTTP authentication in HTTP library,
38
control agent, kea shell and high availability hook.

src/share/api/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ EXTRA_DIST = api_files.mk
66
EXTRA_DIST += README
77
EXTRA_DIST += _template.json
88
EXTRA_DIST += generate-templates
9-
EXTRA_DIST += cmds-list
9+
EXTRA_DIST += generate-api-files
1010
EXTRA_DIST += $(api_files)
1111

1212
install-data-local:

src/share/api/README

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
There are several steps needed to document new API command:
22

3-
1. edit cmds-list and add the new command
4-
2. (optional) run: ./generate-templates cmds-list
5-
This will go through the list of commands listed in cmds-list
6-
and will check if there are corresponding JSON files in api/name.json
3+
1. (optional) run: ./generate-templates cmd1 cmd2...
4+
This will go through the list of commands given in arguments
5+
and will check if there are corresponding JSON files in name.json
76
If the file is missing, a new JSON will be created using template.
87
If you dislike this generator, you can always use _template.json
98
and copy it over under the name of a new command.
10-
3. Edit api/command-name.json. If the command is provided by the daemon
9+
2. Edit command-name.json. If the command is provided by the daemon
1110
out of its own (and not via hook), simply delete the hook entry.
1211
If you don't want to provide command syntax (cmd-syntax key),
1312
any comments about the syntax (cmd-comment key) or response syntax
1413
(resp-syntax) or any comment about response (resp-comment), simply
1514
remove those unused keys. The generator will attempt to generate
1615
boilerplates for it.
16+
3. Update api_files.mk. You can also run: ./generate-api-files > api_files.mk
17+
or check the update by: ./generate-api-files | diff - api_files.mk
1718
4. Rebuild User's Guide as usual, run in doc/sphinx folder: make
1819

1920
Files in this directory:
2021
- README: this file
2122
- _template.json: template used by generate-templates
2223
- api-files.mk: list of command files for inclusion in Makefiles
23-
(build from 'ls [a-z]*.json > api-files.mk')
24-
- cmds-list: list of commands, used as the argument of generate-templates
25-
(build by 'ls [a-z]*.json | sed 's/\.json//' | sort')
26-
- generate-templates: script generating a new command file from the
27-
command list (cmds-list) and the template (_template.json)
24+
(can be build by ./generata-api-files)
25+
- generate-templates: script generating new command files from the
26+
the template (_template.json)
27+
- generate-api-files: script generating api-files.mk

src/share/api/_template.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Note the api/*.json files are to be processed by api2doc.py and possibly other
1+
// Note the *.json files are to be processed by api2doc.py and possibly other
22
// JSON tools that do not handle comments. If using this template, make sure you
33
// have all the comments removed.
44
{

src/share/api/cmds-list

-165
This file was deleted.

src/share/api/generate-api-files

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
# This script generates api_files.mk
4+
# Usage:
5+
#
6+
# ./generate-api-files > api_files.mk
7+
8+
if [ $# -ne 0 ]; then
9+
echo "Usage: ./generate-api-files"
10+
exit
11+
fi
12+
13+
for f in [a-z]*.json ; do
14+
echo "api_files += \$(top_srcdir)/src/share/api/$f"
15+
done

src/share/api/generate-templates

+10-13
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,20 @@
33
# This script generates API documentation templates.
44
# Usage:
55
#
6-
# ./generate-templates file
6+
# ./generate-templates cmd...
77
#
8-
# File is expected to have a list of commands, one per line.
9-
# The templates will be created in api/ directory.
8+
# Arguments are a list of new commands.
9+
# The templates will be created in local directory.
1010

11-
if [ $# != 1 ]; then
12-
echo "Usage: ./generate-templates file"
13-
echo
14-
echo "File specifies a plain text file with each line having name of a command"
11+
if [ $# -eq 0 ]; then
12+
echo "Usage: ./generate-templates cmd..."
1513
exit
1614
fi
1715

18-
19-
mkdir -p api/
20-
21-
while read -r CMD; do
22-
F=api/$CMD.json
16+
while [ $# -ne 0 ]; do
17+
CMD="$1"
18+
shift
19+
F=$CMD.json
2320

2421
if [ -e "$F" ]; then
2522
echo "$F exists, skipping"
@@ -43,4 +40,4 @@ while read -r CMD; do
4340
echo "}" >> "$F"
4441

4542
echo "$CMD generated."
46-
done < "$1"
43+
done

0 commit comments

Comments
 (0)