Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] added f-strings to docs/conf.py #4147

Merged
merged 11 commits into from
Apr 5, 2021
24 changes: 12 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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):
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -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.
Expand All @@ -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):
Expand Down