2727import os
2828import argparse
2929from jinja2 import Template
30- from lib import ApiParser
31-
32- EXCLUDE_CONTROLLERS = ['Core/Api/FirmwareController.php' ]
30+ from lib .utils import collect_api_modules
3331
3432
3533def source_url (repo , src_filename ):
@@ -46,25 +44,9 @@ def source_url(repo, src_filename):
4644 parser .add_argument ('--debug' , help = 'enable debug mode' , default = False , action = 'store_true' )
4745 cmd_args = parser .parse_args ()
4846
49- # collect all endpoints
50- all_modules = dict ()
51- for root , dirs , files in os .walk (cmd_args .source ):
52- for fname in sorted (files ):
53- filename = os .path .join (root , fname )
54- skip = False
55- for to_exclude in EXCLUDE_CONTROLLERS :
56- if filename .endswith (to_exclude ):
57- skip = True
58- break
59- if not skip and filename .lower ().endswith ('controller.php' ) and filename .find ('mvc/app/controllers' ) > - 1 \
60- and root .endswith ('Api' ):
61- payload = ApiParser (filename , cmd_args .debug ).parse_api_php ()
62- if len (payload ) > 0 :
63- if payload ['module' ] not in all_modules :
64- all_modules [payload ['module' ]] = list ()
65- all_modules [payload ['module' ]].append (payload )
6647
6748 # writeout .rst files
49+ all_modules = collect_api_modules (cmd_args .source , cmd_args .debug )
6850 for module_name in all_modules :
6951 target_filename = "%s/source/development/api/%s/%s.rst" % (
7052 os .path .dirname (__file__ ), cmd_args .repo , module_name
0 commit comments