@@ -43,18 +43,29 @@ def get_files_builtin() -> List[str]:
43
43
44
44
return sorted (file_names )
45
45
46
- def get_files_user () -> List [str ]:
47
- """Return the sorted list of all module files provided by collections installed in the
48
- user home folder ~/.ansible/collections/
46
+
47
+ def get_files_collections (user : bool = False ) -> List [str ]:
48
+ """Return the sorted list of all module files provided by collections installed in either
49
+ the system folder /usr/share/ansible/collections/ or user folder ~/.ansible/collections/
50
+
51
+ Parameters
52
+ ----------
53
+ user: bool (default: False)
54
+ A boolean indicating whether to get collections installed in the user folder
49
55
50
56
Returns
51
57
-------
52
58
List[str]
53
- A list of strings representing the Python module files installed in ~/.ansible/ collections/
59
+ A list of strings representing the Python module files provided by collections
54
60
"""
55
61
62
+ if user :
63
+ collection_path = '~/.ansible/collections/ansible_collections/'
64
+ else :
65
+ collection_path = '/usr/share/ansible/collections/ansible_collections/'
66
+
56
67
file_names : List [str ] = []
57
- for root , dirs , files in os .walk (os .path .expanduser ('~/.ansible/collections/ansible_collections/' )):
68
+ for root , dirs , files in os .walk (os .path .expanduser (collection_path )):
58
69
files_without_symlinks = []
59
70
for f in files :
60
71
if not os .path .islink (os .path .join (root , f )):
@@ -353,8 +364,16 @@ def get_collection_name(filepath:str) -> str:
353
364
docstring_builtin ['collection_name' ] = "ansible.builtin"
354
365
modules_docstrings .append (docstring_builtin )
355
366
367
+ system_modules_paths = get_files_collections ()
368
+ for f in system_modules_paths :
369
+ docstring_system = get_module_docstring (f )
370
+ if docstring_system and docstring_system not in modules_docstrings :
371
+ collection_name = get_collection_name (f )
372
+ docstring_system ['collection_name' ] = collection_name
373
+ modules_docstrings .append (docstring_system )
374
+
356
375
if args .user :
357
- user_modules_paths = get_files_user ( )
376
+ user_modules_paths = get_files_collections ( user = True )
358
377
for f in user_modules_paths :
359
378
docstring_user = get_module_docstring (f )
360
379
if docstring_user and docstring_user not in modules_docstrings :
0 commit comments