Unverified Commit b2d73dee authored by NovusEdge's avatar NovusEdge Committed by GitHub
Browse files

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



* Added f-strings to docs/conf.py

* fixed some linting errors

* fixed indent on 210:25

* YAF

* yet another try at fixing the linting

* Try: 1

* Try 2

* Update docs/conf.py
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>

* Update docs/conf.py
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>

* Update docs/conf.py
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>
Co-authored-by: default avatarJames Lamb <jaylamb20@gmail.com>
parent 2885d3e0
...@@ -76,7 +76,7 @@ RTD = bool(os.environ.get('READTHEDOCS', '')) ...@@ -76,7 +76,7 @@ RTD = bool(os.environ.get('READTHEDOCS', ''))
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '2.1.0' # Due to sphinx.ext.napoleon, autodoc_typehints needs_sphinx = '2.1.0' # Due to sphinx.ext.napoleon, autodoc_typehints
if needs_sphinx > sphinx.__version__: 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) raise VersionRequirementError(message)
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be
...@@ -114,7 +114,7 @@ master_doc = 'index' ...@@ -114,7 +114,7 @@ master_doc = 'index'
# General information about the project. # General information about the project.
project = 'LightGBM' project = 'LightGBM'
copyright = '%s, Microsoft Corporation' % str(datetime.datetime.now().year) copyright = f'{datetime.datetime.now().year}, Microsoft Corporation'
author = 'Microsoft Corporation' author = 'Microsoft Corporation'
# The name of an image file (relative to this directory) to place at the top # The name of an image file (relative to this directory) to place at the top
...@@ -206,10 +206,10 @@ def generate_doxygen_xml(app): ...@@ -206,10 +206,10 @@ def generate_doxygen_xml(app):
app : object app : object
The application object representing the Sphinx process. The application object representing the Sphinx process.
""" """
input = os.path.join(CURR_PATH, os.path.pardir, 'include', 'LightGBM', 'c_api.h')
doxygen_args = [ doxygen_args = [
"INPUT={}".format(os.path.join(CURR_PATH, os.path.pardir, f"INPUT={input}",
'include', 'LightGBM', 'c_api.h')), f"OUTPUT_DIRECTORY={os.path.join(CURR_PATH, 'doxyoutput')}",
"OUTPUT_DIRECTORY={}".format(os.path.join(CURR_PATH, 'doxyoutput')),
"GENERATE_HTML=NO", "GENERATE_HTML=NO",
"GENERATE_LATEX=NO", "GENERATE_LATEX=NO",
"GENERATE_XML=YES", "GENERATE_XML=YES",
...@@ -242,7 +242,7 @@ def generate_doxygen_xml(app): ...@@ -242,7 +242,7 @@ def generate_doxygen_xml(app):
else: else:
print(output) print(output)
except BaseException as e: 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): def generate_r_docs(app):
...@@ -253,7 +253,7 @@ def generate_r_docs(app): ...@@ -253,7 +253,7 @@ def generate_r_docs(app):
app : object app : object
The application object representing the Sphinx process. The application object representing the Sphinx process.
""" """
commands = """ commands = f"""
/home/docs/.conda/bin/conda create \ /home/docs/.conda/bin/conda create \
-q \ -q \
-y \ -y \
...@@ -268,10 +268,10 @@ def generate_r_docs(app): ...@@ -268,10 +268,10 @@ def generate_r_docs(app):
r-roxygen2=7.1.1=r40h0357c0b_0 r-roxygen2=7.1.1=r40h0357c0b_0
source /home/docs/.conda/bin/activate r_env source /home/docs/.conda/bin/activate r_env
export TAR=/bin/tar export TAR=/bin/tar
cd {0} cd {os.path.join(CURR_PATH, os.path.pardir)}
export R_LIBS="$CONDA_PREFIX/lib/R/library" export R_LIBS="$CONDA_PREFIX/lib/R/library"
Rscript build_r.R || exit -1 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 "roxygen2::roxygenize(load = 'installed')" || exit -1
Rscript -e "pkgdown::build_site( \ Rscript -e "pkgdown::build_site( \
lazy = FALSE \ lazy = FALSE \
...@@ -284,8 +284,8 @@ def generate_r_docs(app): ...@@ -284,8 +284,8 @@ def generate_r_docs(app):
, new_process = TRUE \ , new_process = TRUE \
) )
" || exit -1 " || exit -1
cd {0} cd {os.path.join(CURR_PATH, os.path.pardir)}
""".format(os.path.join(CURR_PATH, os.path.pardir), os.path.join(CURR_PATH, os.path.pardir, "lightgbm_r")) """
try: try:
# Warning! The following code can cause buffer overflows on RTD. # Warning! The following code can cause buffer overflows on RTD.
# Consider suppressing output completely if RTD project silently fails. # Consider suppressing output completely if RTD project silently fails.
...@@ -301,7 +301,7 @@ def generate_r_docs(app): ...@@ -301,7 +301,7 @@ def generate_r_docs(app):
else: else:
print(output) print(output)
except BaseException as e: 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): def setup(app):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment