@@ -235,7 +235,8 @@ def get_functions_and_classes(package):
235235 return classes , functions
236236
237237
238- def generate_api_docs (package , api_dir , clean = False , printlog = True ):
238+ def generate_api_docs (package , api_dir , clean = False ,
239+ printlog = True , ignore_packages = None ):
239240 """Generate a module level API documentation of a python package.
240241
241242 Description
@@ -253,6 +254,11 @@ def generate_api_docs(package, api_dir, clean=False, printlog=True):
253254 Removes previously existing API directory if True.
254255 printlog : bool (default: True)
255256 Prints a progress log to the standard output screen if True.
257+ ignore_packages : iterable or None (default: None)
258+ Iterable (list, set, tuple) that contains the names of packages
259+ and subpackages to ignore or skip. For instance, if the
260+ images subpackage in mlxtend is supposed to be split, provide the
261+ argument `{mlxtend.image}`.
256262
257263 """
258264 if printlog :
@@ -269,6 +275,11 @@ def generate_api_docs(package, api_dir, clean=False, printlog=True):
269275 api_docs = {}
270276 for importer , pkg_name , is_pkg in pkgutil .iter_modules (
271277 package .__path__ , prefix ):
278+
279+ if ignore_packages is not None and pkg_name in ignore_packages :
280+ if printlog :
281+ print ('ignored %s' % pkg_name )
282+ continue
272283 if is_pkg :
273284 subpackage = __import__ (pkg_name , fromlist = "dummy" )
274285 prefix = subpackage .__name__ + "."
@@ -418,7 +429,7 @@ def summarize_methdods_and_functions(api_modules, out_dir,
418429 parser .add_argument ('-o2' , '--output_subpackage_api' ,
419430 default = '../docs/sources/api_subpackages' ,
420431 help = ('Target directory for the'
421- 'subpackage-level API Markdown files' ))
432+ ' subpackage-level API Markdown files' ))
422433 parser .add_argument ('-c' , '--clean' ,
423434 action = 'store_true' ,
424435 help = 'Remove previous API files' )
@@ -428,13 +439,24 @@ def summarize_methdods_and_functions(api_modules, out_dir,
428439 parser .add_argument ('-v' , '--version' ,
429440 action = 'version' ,
430441 version = 'v. 0.1' )
442+ parser .add_argument ('--ignore_packages' ,
443+ default = '' ,
444+ help = 'Ignores subpackages listed via this option.'
445+ ' For example, to ignore mlxtend.image,'
446+ ' type "mlxtend.image".'
447+ ' For multiple subpackages, separate them via,'
448+ ' commas. For example,'
449+ ' "mlxtend.image,mlxtend.plotting".' )
431450
432451 args = parser .parse_args ()
433452
453+ ignore_packages_set = set (args .ignore_packages .split ("," ))
454+
434455 package = import_package (args .package_dir , args .package_name )
435456 generate_api_docs (package = package ,
436457 api_dir = args .output_module_api ,
437458 clean = args .clean ,
459+ ignore_packages = ignore_packages_set ,
438460 printlog = not (args .silent ))
439461 summarize_methdods_and_functions (api_modules = args .output_module_api ,
440462 out_dir = args .output_subpackage_api ,
0 commit comments