Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,6 @@ them.

Solution: see the :ref:`quickstart_clean_target` section of the Quickstart guide.

Unicode support?
----------------------------------------------------------------------------------------

Every action Exhale performs with respect to strings is done using unicode strings. Or
at least I tried my very best to make sure unicode support works.

1. At the top of every file:

.. code-block:: py

from __future__ import unicode_literals

This is why all of the documentation on this site for strings has a leading ``u``.

2. Every file written to:

.. code-block:: py

with codecs.open(file_name, "w", "utf-8") as f:

3. When using Python **3**, ``bytes`` conversion is done as:

.. code-block:: py

doxygen_input = bytes(doxygen_input, "utf-8")

The last one may *potentially* cause problems, but in local testing it seems to be OK.
E.g., if you only specify **ASCII** in your ``conf.py``, everything should work out
in the end.

.. note::

Sphinx / reStructuredText supports ``utf-8`` no problem. The only potential concern
is communicating with Doxygen on stdin like this, but it's worked without issue
for me so I kept it. Please speak up if you are experiencing encoding / decoding
specific issues in Exhale!

Why does my documentation take so long to build?
----------------------------------------------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ sphinx-issues
beautifulsoup4
lxml
breathe
six
# test imports
pytest
pytest-raises>=0.10
2 changes: 0 additions & 2 deletions exhale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# https://github.com/svenevs/exhale/blob/master/LICENSE #
########################################################################################

from __future__ import unicode_literals

__version__ = "0.3.8.dev"


Expand Down
69 changes: 30 additions & 39 deletions exhale/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,15 @@
options are to modify the behavior of Exhale.
'''

from __future__ import unicode_literals

import os
import six
import textwrap
from io import StringIO
from pathlib import Path

from sphinx.errors import ConfigError, ExtensionError
from sphinx.util import logging
from types import FunctionType, ModuleType

try:
# Python 2 StringIO
from cStringIO import StringIO
except ImportError:
# Python 3 StringIO
from io import StringIO


logger = logging.getLogger(__name__)
"""
Expand Down Expand Up @@ -1337,7 +1328,7 @@ def apply_sphinx_configurations(app):
breathe_default_project = app.config.breathe_default_project
if not breathe_default_project:
raise ConfigError("You must set the `breathe_default_project` in `conf.py`.")
elif not isinstance(breathe_default_project, six.string_types):
elif not isinstance(breathe_default_project, str):
raise ConfigError("The type of `breathe_default_project` must be a string.")

if breathe_default_project not in breathe_projects:
Expand All @@ -1351,7 +1342,7 @@ def apply_sphinx_configurations(app):
# defer validation of existence until after potentially running Doxygen based on
# the configs given to exhale
doxy_xml_dir = breathe_projects[breathe_default_project]
if not isinstance(doxy_xml_dir, six.string_types):
if not isinstance(doxy_xml_dir, str):
raise ConfigError(
"The type of `breathe_projects[breathe_default_project]` from `conf.py` was not a string."
)
Expand Down Expand Up @@ -1387,9 +1378,9 @@ def apply_sphinx_configurations(app):
val_error = "The type of the value for key `{key}` must be `{exp}`, but was `{got}`."

req_kv = [
("containmentFolder", six.string_types, True),
("rootFileName", six.string_types, False),
("doxygenStripFromPath", six.string_types, True)
("containmentFolder", str, True),
("rootFileName", str, False),
("doxygenStripFromPath", str, True)
]
for key, expected_type, make_absolute in req_kv:
# Used in error checking later
Expand Down Expand Up @@ -1472,51 +1463,51 @@ def apply_sphinx_configurations(app):
####################################################################################
# TODO: `list` -> `(list, tuple)`, update docs too.
opt_kv = [
("rootFileTitle", six.string_types),
("rootFileTitle", str),
# Build Process Logging, Colors, and Debugging
("verboseBuild", bool),
("alwaysColorize", bool),
("generateBreatheFileDirectives", bool),
# Root API Document Customization and Treeview
("afterTitleDescription", six.string_types),
("pageHierarchySubSectionTitle", six.string_types),
("afterHierarchyDescription", six.string_types),
("fullApiSubSectionTitle", six.string_types),
("afterBodySummary", six.string_types),
("afterTitleDescription", str),
("pageHierarchySubSectionTitle", str),
("afterHierarchyDescription", str),
("fullApiSubSectionTitle", str),
("afterBodySummary", str),
("fullToctreeMaxDepth", int),
("listingExclude", list),
("unabridgedOrphanKinds", (list, set)),
# Manual Indexing
("classHierarchyFilename", six.string_types),
("fileHierarchyFilename", six.string_types),
("pageHierarchyFilename", six.string_types),
("unabridgedApiFilename", six.string_types),
("unabridgedOrphanFilename", six.string_types),
("classHierarchyFilename", str),
("fileHierarchyFilename", str),
("pageHierarchyFilename", str),
("unabridgedApiFilename", str),
("unabridgedOrphanFilename", str),
# Clickable Hierarchies <3
("createTreeView", bool),
("minifyTreeView", bool),
("treeViewIsBootstrap", bool),
("treeViewBootstrapTextSpanClass", six.string_types),
("treeViewBootstrapIconMimicColor", six.string_types),
("treeViewBootstrapOnhoverColor", six.string_types),
("treeViewBootstrapTextSpanClass", str),
("treeViewBootstrapIconMimicColor", str),
("treeViewBootstrapOnhoverColor", str),
("treeViewBootstrapUseBadgeTags", bool),
("treeViewBootstrapExpandIcon", six.string_types),
("treeViewBootstrapCollapseIcon", six.string_types),
("treeViewBootstrapExpandIcon", str),
("treeViewBootstrapCollapseIcon", str),
("treeViewBootstrapLevels", int),
# Page Level Customization
("includeTemplateParamOrderList", bool),
("pageLevelConfigMeta", six.string_types),
("repoRedirectURL", six.string_types),
("pageLevelConfigMeta", str),
("repoRedirectURL", str),
("contentsDirectives", bool),
("contentsTitle", six.string_types),
("contentsTitle", str),
("contentsSpecifiers", list),
("kindsWithContentsDirectives", list),
# Breathe Customization
("customSpecificationsMapping", dict),
# Doxygen Execution and Customization
("exhaleExecutesDoxygen", bool),
("exhaleUseDoxyfile", bool),
("exhaleDoxygenStdin", six.string_types),
("exhaleDoxygenStdin", str),
("exhaleSilentDoxygen", bool),
# Programlisting Customization
("lexerMapping", dict)
Expand Down Expand Up @@ -1546,7 +1537,7 @@ def apply_sphinx_configurations(app):
# These two need to be lists of strings, check to make sure
def _list_of_strings(lst, title):
for spec in lst:
if not isinstance(spec, six.string_types):
if not isinstance(spec, str):
raise ConfigError(
"`{title}` must be a list of strings. `{spec}` was of type `{spec_t}`".format(
title=title,
Expand Down Expand Up @@ -1590,7 +1581,7 @@ def item_or_index(item, idx):
for idx in range(len(exclusions)):
# Gather the `pattern` and `flags` parameters for `re.compile`
item = exclusions[idx]
if isinstance(item, six.string_types):
if isinstance(item, str):
pattern = item
flags = 0
else:
Expand Down Expand Up @@ -1624,7 +1615,7 @@ def item_or_index(item, idx):
for key in lexer_mapping:
val = lexer_mapping[key]
# Make sure both are strings
if not isinstance(key, six.string_types) or not isinstance(val, six.string_types):
if not isinstance(key, str) or not isinstance(val, str):
raise ConfigError("All keys and values in `lexerMapping` must be strings.")
# Make sure the key is a valid regular expression
try:
Expand Down Expand Up @@ -1766,7 +1757,7 @@ def similar(a, b):
# Sanity check #3: make sure the return values are all strings
for key in customSpecificationsMapping:
val_t = type(customSpecificationsMapping[key])
if not isinstance(key, six.string_types):
if not isinstance(key, str):
raise ConfigError(
"`customSpecificationsMapping` key `{key}` gave value type `{val_t}` (need `str`).".format(
key=key, val_t=val_t
Expand Down
19 changes: 5 additions & 14 deletions exhale/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@
2. Launching the full API generation via the :func:`~exhale.deploy.explode` function.
'''

from __future__ import unicode_literals

from . import configs
from . import utils
from .graph import ExhaleRoot

import os
import sys
import six
import re
import codecs
import tempfile
Expand Down Expand Up @@ -80,7 +77,7 @@ def _generate_doxygen(doxygen_input):
method to restore some state before exiting the program (namely, the working
directory before propagating an exception to ``sphinx-build``).
'''
if not isinstance(doxygen_input, six.string_types):
if not isinstance(doxygen_input, str):
return "Error: the `doxygen_input` variable must be of type `str`."

doxyfile = doxygen_input == "Doxyfile"
Expand All @@ -106,11 +103,8 @@ def _generate_doxygen(doxygen_input):
#
# See excellent synopsis:
# https://thraxil.org/users/anders/posts/2008/03/13/Subprocess-Hanging-PIPE-is-your-enemy/
if six.PY2:
tempfile_kwargs = {}
else:
# encoding argument introduced in python 3
tempfile_kwargs = {"encoding": "utf-8"}
# encoding argument introduced in python 3
tempfile_kwargs = {"encoding": "utf-8"}
tempfile_kwargs["mode"] = "r+"
tmp_out_file = tempfile.TemporaryFile(
prefix="doxygen_stdout_buff", **tempfile_kwargs
Expand All @@ -129,10 +123,7 @@ def _generate_doxygen(doxygen_input):

# Communicate can only be called once, arrange whether or not stdin has value
if not doxyfile:
# In Py3, make sure we are communicating a bytes-like object which is no
# longer interchangeable with strings (as was the case in Py2).
if sys.version[0] == "3":
doxygen_input = bytes(doxygen_input, "utf-8")
doxygen_input = bytes(doxygen_input, "utf-8")
comm_kwargs = {"input": doxygen_input}
else:
comm_kwargs = {}
Expand Down Expand Up @@ -215,7 +206,7 @@ def generateDoxygenXML():
# 1. INPUT (where doxygen should parse).
#
# The below is a modest attempt to validate that these were / were not given.
if not isinstance(configs.exhaleDoxygenStdin, six.string_types):
if not isinstance(configs.exhaleDoxygenStdin, str):
return "`exhaleDoxygenStdin` config must be a string!"

if not _valid_config("OUTPUT_DIRECTORY", False):
Expand Down
16 changes: 3 additions & 13 deletions exhale/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# https://github.com/svenevs/exhale/blob/master/LICENSE #
########################################################################################

from __future__ import unicode_literals

from . import configs
from . import parse
from . import utils
Expand All @@ -24,12 +22,7 @@

from bs4 import BeautifulSoup

try:
# Python 2 StringIO
from cStringIO import StringIO
except ImportError:
# Python 3 StringIO
from io import StringIO
from io import StringIO

__all__ = ["ExhaleRoot", "ExhaleNode"]

Expand Down Expand Up @@ -4038,11 +4031,8 @@ class view hierarchy. It will be present in the file page it was declared in
- Directories
- Files
'''
try:
from collections.abc import MutableMapping
except ImportError:
# TODO: remove when dropping python 2.7
from collections import MutableMapping
from collections.abc import MutableMapping

class UnabridgedDict(MutableMapping):
def __init__(self):
self.items = {}
Expand Down
2 changes: 0 additions & 2 deletions exhale/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# https://github.com/svenevs/exhale/blob/master/LICENSE #
########################################################################################

from __future__ import unicode_literals

from . import configs
from . import utils

Expand Down
14 changes: 5 additions & 9 deletions exhale/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# https://github.com/svenevs/exhale/blob/master/LICENSE #
########################################################################################

from __future__ import unicode_literals, annotations
from __future__ import annotations
from typing import TextIO, Union

from . import configs
Expand All @@ -18,7 +18,6 @@
import os
import re
import sys
import six
import textwrap
import time
import traceback
Expand Down Expand Up @@ -98,11 +97,8 @@ def time_string(start, end):


def get_time():
if sys.version_info > (3, 3):
# monotonic introduced in 3.3
return time.monotonic()
else:
return time.time()
# monotonic introduced in 3.3
return time.monotonic()


AVAILABLE_KINDS = [
Expand Down Expand Up @@ -227,7 +223,7 @@ def makeCustomSpecificationsMapping(func):
specs = func(kind)
bad = type(specs) is not list
for s in specs:
if not isinstance(s, six.string_types):
if not isinstance(s, str):
bad = True
break
if bad:
Expand Down Expand Up @@ -690,7 +686,7 @@ def printAllColorsToConsole(cls):
# ignore specials such as __class__ or __module__
if not elem.startswith("__"):
color_fmt = cls.__dict__[elem]
if isinstance(color_fmt, six.string_types) and color_fmt != "BOLD" and color_fmt != "DIM" and \
if isinstance(color_fmt, str) and color_fmt != "BOLD" and color_fmt != "DIM" and \
color_fmt != "UNDER" and color_fmt != "INV":
print("\033[{fmt}AnsiColors.{name}\033[0m".format(fmt=color_fmt, name=elem))

Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ install_requires =
Sphinx>=4.3.2
beautifulsoup4
lxml
# TODO: remove this dependency
six

[options.package_data]
# NOTE: UserWarning from setuptools about newlines in SOURCES.txt. Not sure
Expand Down
1 change: 0 additions & 1 deletion testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
The testing package for Exhale.
"""

from __future__ import unicode_literals
import os


Expand Down
Loading