Skip to content

Commit

Permalink
Merge pull request #33 from astrofrog/ascii-locale
Browse files Browse the repository at this point in the history
Add a test configuration with a default ASCII locale
  • Loading branch information
astrofrog authored Jul 4, 2017
2 parents 2f7d600 + 462dea4 commit 7632f0b
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,24 @@ env:
- PYTHON_VERSION=3.5 SPHINX_VERSION=1.5
- PYTHON_VERSION=3.6 SPHINX_VERSION=1.6 CONDA_CHANNELS="conda-forge"
- PYTHON_VERSION=3.6 SPHINX_VERSION=dev CONDA_DEPENDENCIES="setuptools cython pytest-cov"
- PYTHON_VERSION=2.7 LOCALE=C
- PYTHON_VERSION=3.6 LOCALE=C
global:
- LOCALE=default
- CONDA_DEPENDENCIES="setuptools sphinx cython pytest-cov"
- PIP_DEPENDENCIES="coveralls"
- HOMEBREW_NO_AUTO_UPDATE=1

before_install:

# Make sure that things work even if the locale is set to C (which effectively means ASCII).
# Some of the input rst files have unicode characters and we need to deal with this gracefully.
- if [[ $LOCALE == C ]]; then
export LC_CTYPE=C;
export LC_ALL=C;
export LANG=C;
fi

- if [[ $TRAVIS_OS_NAME == osx ]]; then brew install graphviz; fi

install:
Expand Down
3 changes: 2 additions & 1 deletion sphinx_automodapi/automodsumm.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class members that are inherited from a base class. This value can be
import inspect
import os
import re
import io

from sphinx.ext.autosummary import Autosummary
from sphinx.ext.inheritance_diagram import InheritanceDiagram
Expand Down Expand Up @@ -305,7 +306,7 @@ def automodsumm_to_autosummary_lines(fn, app):

fullfn = os.path.join(app.builder.env.srcdir, fn)

with open(fullfn) as fr:
with io.open(fullfn, encoding='utf8') as fr:
# Note: we use __name__ here instead of just writing the module name in
# case this extension is bundled into another package
from . import automodapi
Expand Down
1 change: 1 addition & 0 deletions sphinx_automodapi/tests/cases/non_ascii/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Non-ASCII characters
3 changes: 3 additions & 0 deletions sphinx_automodapi/tests/cases/non_ascii/input/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Ceçi est un exemple qui inclus des charactères non-ASCII

.. automodapi:: sphinx_automodapi.tests.example_module.functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
add
===

.. currentmodule:: sphinx_automodapi.tests.example_module.functions

.. autofunction:: add
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
multiply
========

.. currentmodule:: sphinx_automodapi.tests.example_module.functions

.. autofunction:: multiply
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Ceçi est un exemple qui inclus des charactères non-ASCII


sphinx_automodapi.tests.example_module.functions Module
-------------------------------------------------------

.. automodule:: sphinx_automodapi.tests.example_module.functions

Functions
^^^^^^^^^

.. automodsumm:: sphinx_automodapi.tests.example_module.functions
:functions-only:
:toctree: api
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. currentmodule:: sphinx_automodapi.tests.example_module.functions

.. autosummary::
:toctree: api

add
multiply
5 changes: 3 additions & 2 deletions sphinx_automodapi/tests/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# We store different cases in the cases sub-directory of the tests directory

import os
import io
import sys
import glob
import shutil
Expand Down Expand Up @@ -109,6 +110,6 @@ def test_run_full_case(tmpdir, case_dir):
path_relative = os.path.relpath(path_reference, output_dir)
path_actual = os.path.join(docs_dir, path_relative)
assert os.path.exists(path_actual)
actual = open(path_actual).read()
reference = open(path_reference).read()
actual = io.open(path_actual, encoding='utf8').read()
reference = io.open(path_reference, encoding='utf8').read()
assert actual.strip() == reference.strip()

0 comments on commit 7632f0b

Please sign in to comment.