diff --git a/docs/conf.py b/docs/conf.py index a894d4b76873..637447ed627c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -76,7 +76,7 @@ def run(self): # If your documentation needs a minimal Sphinx version, state it here. needs_sphinx = '2.1.0' # Due to sphinx.ext.napoleon, autodoc_typehints if needs_sphinx > sphinx.__version__: - message = 'This project needs at least Sphinx v%s' % needs_sphinx + message = f'This project needs at least Sphinx v{needs_sphinx}' raise VersionRequirementError(message) # Add any Sphinx extension module names here, as strings. They can be @@ -114,7 +114,7 @@ def run(self): # General information about the project. project = 'LightGBM' -copyright = '%s, Microsoft Corporation' % str(datetime.datetime.now().year) +copyright = f'{datetime.datetime.now().year}, Microsoft Corporation' author = 'Microsoft Corporation' # The name of an image file (relative to this directory) to place at the top @@ -206,10 +206,10 @@ def generate_doxygen_xml(app): app : object The application object representing the Sphinx process. """ + input = os.path.join(CURR_PATH, os.path.pardir, 'include', 'LightGBM', 'c_api.h') doxygen_args = [ - "INPUT={}".format(os.path.join(CURR_PATH, os.path.pardir, - 'include', 'LightGBM', 'c_api.h')), - "OUTPUT_DIRECTORY={}".format(os.path.join(CURR_PATH, 'doxyoutput')), + f"INPUT={input}", + f"OUTPUT_DIRECTORY={os.path.join(CURR_PATH, 'doxyoutput')}", "GENERATE_HTML=NO", "GENERATE_LATEX=NO", "GENERATE_XML=YES", @@ -242,7 +242,7 @@ def generate_doxygen_xml(app): else: print(output) except BaseException as e: - raise Exception("An error has occurred while executing Doxygen\n" + str(e)) + raise Exception(f"An error has occurred while executing Doxygen\n{e}") def generate_r_docs(app): @@ -253,7 +253,7 @@ def generate_r_docs(app): app : object The application object representing the Sphinx process. """ - commands = """ + commands = f""" /home/docs/.conda/bin/conda create \ -q \ -y \ @@ -268,10 +268,10 @@ def generate_r_docs(app): r-roxygen2=7.1.1=r40h0357c0b_0 source /home/docs/.conda/bin/activate r_env export TAR=/bin/tar - cd {0} + cd {os.path.join(CURR_PATH, os.path.pardir)} export R_LIBS="$CONDA_PREFIX/lib/R/library" Rscript build_r.R || exit -1 - cd {1} + cd {os.path.join(CURR_PATH, os.path.pardir, "lightgbm_r")} Rscript -e "roxygen2::roxygenize(load = 'installed')" || exit -1 Rscript -e "pkgdown::build_site( \ lazy = FALSE \ @@ -284,8 +284,8 @@ def generate_r_docs(app): , new_process = TRUE \ ) " || exit -1 - cd {0} - """.format(os.path.join(CURR_PATH, os.path.pardir), os.path.join(CURR_PATH, os.path.pardir, "lightgbm_r")) + cd {os.path.join(CURR_PATH, os.path.pardir)} + """ try: # Warning! The following code can cause buffer overflows on RTD. # Consider suppressing output completely if RTD project silently fails. @@ -301,7 +301,7 @@ def generate_r_docs(app): else: print(output) except BaseException as e: - raise Exception("An error has occurred while generating documentation for R-package\n" + str(e)) + raise Exception(f"An error has occurred while generating documentation for R-package\n{e}") def setup(app):