11#
2- # Copyright (C) 2020 Arm Mbed . All rights reserved.
2+ # Copyright (C) 2020 Arm. All rights reserved.
33# SPDX-License-Identifier: Apache-2.0
44#
5- """Generates documentation using Pdoc."""
5+ """Generates documentation."""
6+ import argparse
7+ import logging
68import os
79import shutil
810import sys
9-
10- import argparse
11- import logging
1211from pathlib import Path
13- from subprocess import check_call
14- from typing import List
1512
13+ from continuous_delivery_scripts .language_specifics import get_language_specifics
1614from continuous_delivery_scripts .utils .configuration import configuration , ConfigurationVariable
17- from continuous_delivery_scripts .utils .filesystem_helpers import TemporaryDirectory
1815from continuous_delivery_scripts .utils .logging import log_exception
1916
2017logger = logging .getLogger (__name__ )
@@ -26,40 +23,11 @@ def _clear_previous_docs(output_directory: Path) -> None:
2623 shutil .rmtree (str (output_directory ))
2724
2825
29- def _generate_pdoc_command_list (output_directory : Path , module : str ) -> List [str ]:
30- return [
31- "pdoc" ,
32- "--html" ,
33- f"{ module } " ,
34- "--output-dir" ,
35- f"{ str (output_directory )} " ,
36- "--force" ,
37- "--config" ,
38- "show_type_annotations=True" ,
39- ]
40-
41-
4226def generate_documentation (output_directory : Path , module_to_document : str ) -> None :
43- """Ensures the documentation is in the correct location.
44-
45- Pdoc nests its docs output in a folder with the module's name.
46- This process removes this unwanted folder.
47- """
27+ """Generates the documentation."""
4828 _clear_previous_docs (output_directory )
4929 os .makedirs (str (output_directory ), exist_ok = True )
50- with TemporaryDirectory () as temp_dir :
51- _call_pdoc (temp_dir , module_to_document )
52- docs_contents_dir = temp_dir .joinpath (module_to_document )
53- if docs_contents_dir .exists () and docs_contents_dir .is_dir ():
54- for element in docs_contents_dir .iterdir ():
55- shutil .move (str (element ), str (output_directory ))
56-
57-
58- def _call_pdoc (output_directory : Path , module : str ) -> None :
59- """Calls Pdoc for generating the docs."""
60- logger .info ("Creating Pdoc documentation." )
61- command_list = _generate_pdoc_command_list (output_directory , module )
62- check_call (command_list )
30+ get_language_specifics ().generate_code_documentation (output_directory , module_to_document )
6331
6432
6533def generate_docs (output_directory : Path , module : str ) -> int :
0 commit comments