8000 Resolves conflicts and fixes tests to follow master evolution · pyodide/sphinx-js@668c833 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 668c833

Browse files
committed
Resolves conflicts and fixes tests to follow master evolution
2 parents 38b7975 + aa7f42a commit 668c833

37 files changed

+142
-42
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ addons:
66
- npm
77
python:
88
- "2.7"
9-
- "3.3"
109
- "3.6"
1110
install:
1211
- npm install jsdoc@3.5.5

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
license='MIT',
2020
packages=find_packages(exclude=['ez_setup']),
2121
tests_require=['nose',
22+
'recommonmark==0.4.0',
2223
# Sphinx's plain-text renderer changes behavior slightly
2324
# with regard to how it emits class names and em dashes from
2425
# time to time:
25-
'Sphinx==1.6.5'],
26+
'Sphinx==1.7.2'],
2627
test_suite='nose.collector',
2728
url='https://github.com/erikrose/sphinx-js',
2829
include_package_data=True,

sphinx_js/jsdoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from json import load
44
import os
55
from os.path import abspath, relpath, splitext, sep
6-
from subprocess import PIPE, Popen
6+
from subprocess import Popen
77
from tempfile import TemporaryFile
88

99
from six import string_types

sphinx_js/renderers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class JsRenderer(object):
2424
2525
"""
2626
def __init__(self, directive, app, arguments=None, content=None, options=None):
27+
# Fix crash when calling eval_rst with CommonMarkParser:
28+
if not hasattr(directive.state.document.settings, 'tab_width'):
29+
directive.state.document.settings.tab_width = 8
30+
2731
self._directive = directive
2832

2933
# content, arguments, options, app: all need to be accessible to
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/test_build/source/docs/index.rst

Whitespace-only changes.
File renamed without changes.

tests/test_build.py renamed to tests/test_build/test_build.py

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,15 @@
11
# -*- coding: utf-8 -*-
2-
from io import open
3-
from os.path import dirname, join
4-
from shutil import rmtree
5-
from unittest import TestCase
2+
from nose.tools import assert_in, assert_not_in
63

7-
from nose.tools import eq_, assert_in, assert_not_in
8-
from sphinx.cmdline import main as sphinx_main
9-
from sphinx.util.osutil import cd
4+
from tests.testing import SphinxBuildTestCase
105

116

12-
class Tests(TestCase):
7+
class Tests(SphinxBuildTestCase):
138
"""Tests which require our one big Sphinx tree to be built.
149
1510
Yes, it's too coupled.
1611
1712
"""
18-
@classmethod
19-
def setup_class(cls):
20-
cls.docs_dir = join(dirname(__file__), 'source', 'docs')
21-
with cd(cls.docs_dir):
22-
if sphinx_main(['dummy', '-b', 'text', '-E', '.', '_build']):
23-
raise RuntimeError('Sphinx build exploded.')
24-
25-
def _file_contents(self, filename):
26-
with open(join(self.docs_dir, '_build', '%s.txt' % filename),
27-
encoding='utf8') as file:
28-
return file.read()
29-
30-
def _file_contents_eq(self, filename, contents):
31-
eq_(self._file_contents(filename), contents)
32-
3313
def test_autofunction_minimal(self):
3414
"""Make sure we render correctly and pull the params out of the JS code
3515
when only the function name is provided."""
@@ -62,13 +42,13 @@ def test_autofunction_typedef(self):
6242
"""Make sure @typedef uses can be documented with autofunction."""
6343
self._file_contents_eq(
6444
'autofunction_typedef',
65-
u'TypeDefinition()\n\n Arguments:\n * **width** (*Number*) width in pixels\n')
45+
u'TypeDefinition()\n\n Arguments:\n * **width** (*Number*) -- width in pixels\n')
6646

6747
def test_autofunction_callback(self):
6848
"""Make sure @callback uses can be documented with autofunction."""
6949
self._file_contents_eq(
7050
'autofunction_callback',
71-
u'requestCallback(responseCode)\n\n Some global callback\n\n Arguments:\n * **responseCode** (*number*) \n')
51+
u'requestCallback(responseCode)\n\n Some global callback\n\n Arguments:\n * **responseCode** (*number*) --\n')
7252

7353
def test_autofunction_example(self):
7454
"""Make sure @example tags can be documented with autofunction."""
@@ -87,10 +67,10 @@ def test_autofunction_destructured_params(self):
8767
'autofunction_destructured_params',
8868
u'destructuredParams(p1, p2)\n\n'
8969
u' Arguments:\n'
90-
u' * **p1** (*Number*) \n\n'
91-
u' * **p2** (*Object*) \n\n'
92-
u' * **p2.foo** (*String*) \n\n'
93-
u' * **p2.bar** (*String*) \n')
70+
u' * **p1** (*Number*) --\n\n'
71+
u' * **p2** (*Object*) --\n\n'
72+
u' * **p2.foo** (*String*) --\n\n'
73+
u' * **p2.bar** (*String*) --\n')
9474

9575
def test_autoclass(self):
9676
"""Make sure classes show their class comment and constructor
@@ -109,7 +89,7 @@ def test_autoclass_members(self):
10989
"""
11090
self._file_contents_eq(
11191
'autoclass_members',
112-
u'class ContainingClass(ho)\n\n Class doc.\n\n Constructor doc.\n\n Arguments:\n * **ho** A thing\n\n ContainingClass.anotherMethod()\n\n Another.\n\n ContainingClass.bar\n\n Setting this also frobs the frobnicator.\n\n ContainingClass.someMethod(hi)\n\n Here.\n\n ContainingClass.someVar\n\n A var\n\n ContainingClass.yetAnotherMethod()\n\n More.\n')
92+
u'class ContainingClass(ho)\n\n Class doc.\n\n Constructor doc.\n\n Arguments:\n * **ho** -- A thing\n\n ContainingClass.anotherMethod()\n\n Another.\n\n ContainingClass.bar\n\n Setting this also frobs the frobnicator.\n\n ContainingClass.someMethod(hi)\n\n Here.\n\n ContainingClass.someVar\n\n A var\n\n ContainingClass.yetAnotherMethod()\n\n More.\n')
11393

11494
def test_autoclass_members_list(self):
11595
"""Make sure including a list of names after ``members`` limits it to
@@ -124,7 +104,7 @@ def test_autoclass_members_list_star(self):
124104
at that point."""
125105
self._file_contents_eq(
126106
'autoclass_members_list_star',
127-
u'class ContainingClass(ho)\n\n Class doc.\n\n Constructor doc.\n\n Arguments:\n * **ho** A thing\n\n ContainingClass.bar\n\n Setting this also frobs the frobnicator.\n\n ContainingClass.anotherMethod()\n\n Another.\n\n ContainingClass.someVar\n\n A var\n\n ContainingClass.yetAnotherMethod()\n\n More.\n\n ContainingClass.someMethod(hi)\n\n Here.\n')
107+
u'class ContainingClass(ho)\n\n Class doc.\n\n Constructor doc.\n\n Arguments:\n * **ho** -- A thing\n\n ContainingClass.bar\n\n Setting this also frobs the frobnicator.\n\n ContainingClass.anotherMethod()\n\n Another.\n\n ContainingClass.someVar\n\n A var\n\n ContainingClass.yetAnotherMethod()\n\n More.\n\n ContainingClass.someMethod(hi)\n\n Here.\n')
128108

129109
def test_autoclass_alphabetical(self):
130110
"""Make sure members sort alphabetically when not otherwise specified."""
@@ -184,10 +164,6 @@ def test_no_shadowing(self):
184164
'avoid_shadowing',
185165
'more_code.shadow()\n\n Another thing named shadow, to threaten to shadow the one in\n code.js\n')
186166

187-
@classmethod
188-
def teardown_class(cls):
189-
rmtree(join(cls.docs_dir, '_build'))
190-
191167

192168
DESCRIPTION = """
193169
@@ -197,14 +173,14 @@ def teardown_class(cls):
197173
FIELDS = u"""
198174
199175
Arguments:
200-
* **node** (*Node*) Something of a single type
176+
* **node** (*Node*) -- Something of a single type
201177
202178
Throws:
203-
**PartyError|FartyError** Something with multiple types and a
179+
**PartyError|FartyError** -- Something with multiple types and a
204180
line that wraps
205181
206182
Returns:
207-
**Number** What a thing
183+
**Number** -- What a thing
208184
"""
209185

210186
# Oddly enough, the text renderer renders these bullets with a blank line

tests/test_common_mark/source/code.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* Foo.
3+
*/
4+
function foo() {
5+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env python3
2+
3+
from recommonmark.transform import AutoStructify
4+
from recommonmark.parser import CommonMarkParser
5+
6+
author = 'Jam Risser'
7+
8+
copyright = '2018, Jam Risser'
9+
10+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
11+
12+
extensions = [
13+
'sphinx.ext.mathjax',
14+
'sphinx_js'
15+
]
16+
17+
html_static_path = ['_static']
18+
19+
html_theme = 'sphinx_rtd_theme'
20+
21+
htmlhelp_basename = 'sphinx_hello_worlddoc'
22+
23+
language = None
24+
25+
master_doc = 'index'
26+
27+
needs_sphinx = '1.0'
28+
29+
#primary_domain = 'js'
30+
31+
project = 'sphinx-hello-world'
32+
33+
pygments_style = 'sphinx'
34+
35+
release = '0.0.1'
36+
37+
source_parsers = {
38+
'.md': CommonMarkParser
39+
}
40+
41+
source_suffix = ['.rst', '.md']
42+
43+
templates_path = ['_templates']
44+
45+
todo_include_todos = False
46+
47+
version = '0.0.1'
48+
49+
def setup(app):
50+
app.add_config_value('recommonmark_config', {
51+
'auto_toc_tree_section': 'Content',
52+
'enable_auto_doc_ref': True,
53+
'enable_auto_toc_tree': True,
54+
'enable_eval_rst': True,
55+
'enable_inline_math': True,
56+
'enable_math': True
57+
}, True)
58+
app.add_transform(AutoStructify)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```eval_rst
2+
.. js:autofunction:: foo
3+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from tests.testing import SphinxBuildTestCase
2+
3+
4+
class Tests(SphinxBuildTestCase):
5+
def test_build_success(self):
6+
"""Mostly just test that the build doesn't crash, which is what used to
7+
happen before we added the tab_width workaround.
8+
9+
"""
10+
self._file_contents_eq(
11+
'index',
12+
'foo()\n\n Foo.\n')

tests/testing.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from io import open
2+
from os.path import dirname, join
3+
from shutil import rmtree
4+
from unittest import TestCase
5+
import sys
6+
7+
from nose.tools import eq_
8+
from sphinx.cmdline import main as sphinx_main
9+
from sphinx.util.osutil import cd
10+
11+
12+
class SphinxBuildTestCase(TestCase):
13+
"""Base class for tests which require a Sphinx tree to be built and then
14+
deleted afterward
15+
16+
"""
17+
@classmethod
18+
def setup_class(cls):
19+
"""Run Sphinx against the dir adjacent to the testcase."""
20+
cls.docs_dir = join(cls.this_dir(), 'source', 'docs')
21+
with cd(cls.docs_dir):
22+
if sphinx_main(['.', '-b', 'text', '-E', '_build']):
23+
raise RuntimeError('Sphinx build exploded.')
24+
25+
@classmethod
26+
def teardown_class(cls):
27+
rmtree(join(cls.docs_dir, '_build'))
28+
29+
@classmethod
30+
def this_dir(cls):
31+
"""Return the path to the dir containing the testcase class."""
32+
# nose does some amazing magic that makes this work even if there are
33+
# multiple test modules with the same name:
34+
return dirname(sys.modules[cls.__module__].__file__)
35+
36+
def _file_contents(self, filename):
37+
with open(join(self.docs_dir, '_build', '%s.txt' % filename),
38+
encoding='utf8') as file:
39+
return file.read()
40+
41+
def _file_contents_eq(self, filename, contents):
42+
eq_(self._file_contents(filename), contents)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27, py33, py36
2+
envlist = py27, py36
33

44
[testenv]
55
commands = python setup.py test

0 commit comments

Comments
 (0)
0