aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/doc_gen
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2019-11-12 05:27:43 +0100
committerJan Gelety <jgelety@cisco.com>2019-11-28 18:26:21 +0100
commitd68951ac245150eeefa6e0f4156e4c1b5c9e9325 (patch)
tree487554a7547218d27f0a61ec02b70502c32cdcb4 /resources/tools/doc_gen
parented0258a440cfad7023d643f717ab78ac568dc59b (diff)
Python3: resources and libraries
Change-Id: I1392c06b1d64f62b141d24c0d42a8e36913b15e2 Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources/tools/doc_gen')
-rwxr-xr-xresources/tools/doc_gen/gen_rst.py88
-rw-r--r--resources/tools/doc_gen/src/conf.py56
2 files changed, 72 insertions, 72 deletions
diff --git a/resources/tools/doc_gen/gen_rst.py b/resources/tools/doc_gen/gen_rst.py
index c6d82817ee..28223e22c7 100755
--- a/resources/tools/doc_gen/gen_rst.py
+++ b/resources/tools/doc_gen/gen_rst.py
@@ -16,52 +16,52 @@ from os import walk, listdir
from os.path import isfile, isdir, join, getsize
# Temporary working directory. It is created and deleted by run_doc.sh
-WORKING_DIR = "tmp"
+WORKING_DIR = u"tmp"
# Directory with resources to be documented.
-RESOURCES_DIR = "resources"
+RESOURCES_DIR = u"resources"
# Directory with libraries (python, robot) to be documented.
-LIB_DIR = "libraries"
+LIB_DIR = u"libraries"
# Directory with tests (func, perf) to be documented.
-TESTS_DIR = "tests"
+TESTS_DIR = u"tests"
-PY_EXT = ".py"
-RF_EXT = ".robot"
+PY_EXT = u".py"
+RF_EXT = u".robot"
-PATH_PY_LIBS = join(WORKING_DIR, RESOURCES_DIR, LIB_DIR, "python")
-PATH_RF_LIBS = join(WORKING_DIR, RESOURCES_DIR, LIB_DIR, "robot")
+PATH_PY_LIBS = join(WORKING_DIR, RESOURCES_DIR, LIB_DIR, u"python")
+PATH_RF_LIBS = join(WORKING_DIR, RESOURCES_DIR, LIB_DIR, u"robot")
PATH_TESTS = join(WORKING_DIR, TESTS_DIR)
# Sections in rst files
-rst_toc = """
+rst_toc = u"""
.. toctree::
"""
-rst_py_module = """
+rst_py_module = u"""
.. automodule:: {}.{}
:members:
:undoc-members:
:show-inheritance:
"""
-rst_rf_suite_setup = """
+rst_rf_suite_setup = u"""
.. robot-settings::
:source: {}
"""
-rst_rf_variables = """
+rst_rf_variables = u"""
.. robot-variables::
:source: {}
"""
-rst_rf_keywords = """
+rst_rf_keywords = u"""
.. robot-keywords::
:source: {}
"""
-rst_rf_tests = """
+rst_rf_tests = u"""
.. robot-tests::
:source: {}
"""
@@ -104,9 +104,9 @@ def create_file_name(path, start):
:returns: File name.
:rtype: str
"""
- dir_list = path.split('/')
+ dir_list = path.split(u"/")
start_index = dir_list.index(start)
- return ".".join(dir_list[start_index:-1]) + ".rst"
+ return u".".join(dir_list[start_index:-1]) + u".rst"
def create_rst_file_names_set(files, start):
@@ -139,7 +139,7 @@ def scan_dir(path):
dirs = list()
items = listdir(path)
for item in items:
- if isfile(join(path, item)) and "__init__" not in item:
+ if isfile(join(path, item)) and u"__init__" not in item:
files.append(item)
elif isdir(join(path, item)):
dirs.append(item)
@@ -158,7 +158,7 @@ def write_toc(fh, path, dirs):
"""
fh.write(rst_toc)
for dir in dirs:
- fh.write(" {}.{}\n".format('.'.join(path), dir))
+ fh.write(f" {u'.'.join(path)}.{dir}\n")
def write_module_title(fh, module_name):
@@ -170,20 +170,20 @@ def write_module_title(fh, module_name):
:type fh: BinaryIO
:type module_name: str
"""
- title = "{} suite".format(module_name)
- fh.write("\n{}\n{}\n".format(title, '-' * len(title)))
+ title = f"{module_name} suite"
+ fh.write(f"\n{title}\n{u'-' * len(title)}")
def generate_py_rst_files():
"""Generate all rst files for all python modules."""
- dirs_ignore_list = ["__pycache__", ]
+ dirs_ignore_list = [u"__pycache__", ]
py_libs = get_files(PATH_PY_LIBS, PY_EXT)
file_names = create_rst_file_names_set(py_libs, RESOURCES_DIR)
for file_name in file_names:
- path = join(WORKING_DIR, *file_name.split('.')[:-1])
+ path = join(WORKING_DIR, *file_name.split(u".")[:-1])
dirs, files = scan_dir(path)
for item in dirs_ignore_list:
@@ -194,23 +194,25 @@ def generate_py_rst_files():
break
full_path = join(WORKING_DIR, file_name)
- with open(full_path, mode='a') as fh:
+ with open(full_path, mode="a") as fh:
if getsize(full_path) == 0:
- package = file_name.split('.')[-2]
- fh.write("{}\n".format(package))
- fh.write('=' * len("{}".format(package)))
- module_path = file_name.split('.')[:-1]
+ package = file_name.split(u".")[-2]
+ fh.write(f"{package}\n")
+ fh.write(u"=" * len(f"{package}"))
+ module_path = file_name.split(u".")[:-1]
if dirs:
write_toc(fh, module_path, dirs)
for file in files:
- module_name = file.split('.')[0]
+ module_name = file.split(u".")[0]
write_module_title(fh, module_name)
- fh.write(rst_py_module.format('.'.join(module_path),
- module_name))
+ fh.write(rst_py_module.format(
+ u".".join(module_path), module_name)
+ )
-def generate_rf_rst_files(file_names, incl_tests=True, incl_keywords=True,
- incl_suite_setup=False, incl_variables=False):
+def generate_rf_rst_files(
+ file_names, incl_tests=True, incl_keywords=True, incl_suite_setup=False,
+ incl_variables=False):
"""Generate rst files for the given robot modules.
:param file_names: List of file names to be included in the documentation
@@ -230,20 +232,20 @@ def generate_rf_rst_files(file_names, incl_tests=True, incl_keywords=True,
"""
for file_name in file_names:
- path = join(WORKING_DIR, *file_name.split('.')[:-1])
+ path = join(WORKING_DIR, *file_name.split(u".")[:-1])
dirs, files = scan_dir(path)
full_path = join(WORKING_DIR, file_name)
- with open(full_path, mode='a') as fh:
+ with open(full_path, mode="a") as fh:
if getsize(full_path) == 0:
- package = file_name.split('.')[-2]
- fh.write("{}\n".format(package))
- fh.write('=' * len("{}".format(package)) + '\n')
- module_path = file_name.split('.')[:-1]
+ package = file_name.split(u".")[-2]
+ fh.write(f"{package}\n")
+ fh.write(u"=" * len(f"{package}") + u"\n")
+ module_path = file_name.split(u".")[:-1]
if dirs:
write_toc(fh, module_path, dirs)
for file in files:
- module_name = file.split('.')[0]
+ module_name = file.split(u".")[0]
write_module_title(fh, module_name)
path = join(join(*module_path), module_name + RF_EXT)
if incl_suite_setup:
@@ -273,12 +275,12 @@ def generate_tests_rst_files():
tests = get_files(PATH_TESTS, RF_EXT)
file_names = create_rst_file_names_set(tests, TESTS_DIR)
- generate_rf_rst_files(file_names,
- incl_suite_setup=True,
- incl_variables=True)
+ generate_rf_rst_files(
+ file_names, incl_suite_setup=True, incl_variables=True
+ )
-if __name__ == '__main__':
+if __name__ == u"__main__":
# Generate all rst files:
generate_py_rst_files()
diff --git a/resources/tools/doc_gen/src/conf.py b/resources/tools/doc_gen/src/conf.py
index 1ebbbe7921..9be0baea53 100644
--- a/resources/tools/doc_gen/src/conf.py
+++ b/resources/tools/doc_gen/src/conf.py
@@ -19,7 +19,7 @@
import os
import sys
-sys.path.insert(0, os.path.abspath('.'))
+sys.path.insert(0, os.path.abspath(u"."))
# -- General configuration ------------------------------------------------
@@ -31,31 +31,31 @@ sys.path.insert(0, os.path.abspath('.'))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
- 'sphinx.ext.autodoc',
- 'sphinx.ext.doctest',
- 'sphinxcontrib_robotdoc',
+ u"sphinx.ext.autodoc",
+ u"sphinx.ext.doctest",
+ u"sphinxcontrib_robotdoc"
]
# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
+templates_path = [u"_templates"]
-# The suffix(es) of source filenames.
+# The suffix(es) of source file names.
# You can specify multiple suffix as a list of string:
#
-# source_suffix = ['.rst', '.md']
-source_suffix = '.rst'
+# source_suffix = [u".rst", u".md"]
+source_suffix = u".rst"
# The encoding of source files.
#
# source_encoding = 'utf-8-sig'
# The master toctree document.
-master_doc = 'index'
+master_doc = u"index"
# General information about the project.
-project = u'CSIT'
-copyright = u'2018, FD.io'
-author = u'CSIT'
+project = u"CSIT"
+copyright = u"2018, FD.io"
+author = u"CSIT"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -85,7 +85,7 @@ language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
-exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+exclude_patterns = [u"_build", u"Thumbs.db", u".DS_Store"]
# The reST default role (used for this markup: `text`) to use for all
# documents.
@@ -107,7 +107,7 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
+pygments_style = u"sphinx"
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
@@ -124,8 +124,8 @@ todo_include_todos = False
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
-# html_theme = 'alabaster'
-html_theme = 'sphinx_rtd_theme'
+# html_theme =u"alabaster"
+html_theme = u"sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@@ -134,21 +134,21 @@ html_theme = 'sphinx_rtd_theme'
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
-html_theme_path = ['env/lib/python2.7/site-packages/sphinx_rtd_theme']
+html_theme_path = [u"env/lib/python2.7/site-packages/sphinx_rtd_theme"]
# The name for this set of Sphinx documents.
# "<project> v<release> documentation" by default.
#
-html_title = u'CSIT Documentation'
+html_title = u"CSIT Documentation"
# A shorter title for the navigation bar. Default is the same as html_title.
#
-html_short_title = u'CSIT'
+html_short_title = u"CSIT"
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#
-html_logo = 'fdio_logo.png'
+html_logo = u"fdio_logo.png"
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
@@ -159,7 +159,7 @@ html_logo = 'fdio_logo.png'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
+html_static_path = [u"_static"]
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
@@ -241,7 +241,7 @@ html_show_sourcelink = True
# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
-htmlhelp_basename = 'csitdoc'
+htmlhelp_basename = u"csitdoc"
# -- Options for LaTeX output ---------------------------------------------
@@ -267,8 +267,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
- (master_doc, 'CSIT.tex', u'CSIT Documentation',
- u'CSIT', 'manual'),
+ (master_doc, u"CSIT.tex", u"CSIT Documentation", u"CSIT", u"manual"),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -309,8 +308,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
- (master_doc, 'CSIT', u'CSIT Documentation',
- [author], 1)
+ (master_doc, u"CSIT", u"CSIT Documentation", [author], 1)
]
# If true, show URL addresses after external links.
@@ -324,9 +322,9 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- (master_doc, 'CSIT', u'CSIT Documentation',
- author, 'CSIT', 'One line description of project.',
- 'Miscellaneous'),
+ (master_doc, u"CSIT", u"CSIT Documentation",
+ author, u"CSIT", u"One line description of project.",
+ u"Miscellaneous"),
]
# Documents to append as an appendix to all manuals.