Skip to content

Commit 4bc4a2a

Browse files
authored
fix tests + upgrade doc dependencies (#862)
* fix tests + upgrade doc dependencies * fake the User-Agent
1 parent 1e3fac1 commit 4bc4a2a

File tree

13 files changed

+39
-35
lines changed

13 files changed

+39
-35
lines changed

docs/source/_custom_js/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/source/_exts/async_doctest.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88

99

1010
test_template = """
11-
import asyncio as __asyncio
11+
import asyncio as __test_template_asyncio
1212
13-
async def __run():
13+
async def __test_template__main():
1414
1515
{test}
1616
1717
globals().update(locals())
1818
19-
loop = __asyncio.get_event_loop()
20-
loop.run_until_complete(__run())
19+
__test_template_asyncio.run(__test_template__main())
2120
"""
2221

2322

docs/source/_exts/idom_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def run(self):
8989
[],
9090
{},
9191
_make_tab_items(labeled_tab_items),
92-
self.lineno - 1,
92+
self.lineno - 2,
9393
self.content_offset,
9494
"",
9595
self.state,

docs/source/_exts/idom_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def run(self):
3838
<div>
3939
<div
4040
id="{container_id}"
41-
class="interactive widget-container center-content"
41+
class="interactive widget-container"
4242
style="margin-bottom: {self.options.get("margin", 0)}px;"
4343
/>
4444
<script type="module">

docs/source/_static/css/idom-view.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
width: 100%;
2222
}
2323

24-
.center-content {
25-
display: flex;
26-
align-items: center;
27-
justify-content: center;
28-
}
2924
.enable-widget-button {
3025
padding: 10px;
3126
color: #ffffff !important;

docs/source/_static/css/set-color-scheme.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
#
112112
# This is also used if you do content translation via gettext catalogs.
113113
# Usually you set "language" from the command line for these cases.
114-
language = None
114+
language = "en"
115115

116116
# List of patterns, relative to source directory, that match files and
117117
# directories to ignore when looking for source files.

docs/source/guides/getting-started/installing-idom.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ ensure the modifications you've made are backwards compatible. If you want to ad
107107
feature to IDOM you should write your own test that validates its behavior.
108108

109109
If you have questions about how to modify IDOM or help with its development, be sure to
110-
`start a discussion
111-
<https://github.com/idom-team/idom/discussions/new?category=question>`__. The IDOM team
112-
are always excited to :ref:`welcome <everyone can contribute>` new contributions and
113-
contributors of all kinds
110+
:discussion:`start a discussion <new?category=question>`. The IDOM team are always
111+
excited to :ref:`welcome <everyone can contribute>` new contributions and contributors
112+
of all kinds
114113

115114
.. card::
116115
:link: /about/contributor-guide

requirements/build-docs.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
sphinx ==4.2.0
2-
sphinx-autodoc-typehints ==1.7.0
3-
furo ==2021.10.09
4-
setuptools_scm
5-
sphinx-copybutton ==0.3.0
6-
sphinx-autobuild ==2020.9.1
7-
sphinx-reredirects ==0.0.1
8-
sphinx-design ==0.0.13
9-
sphinx-resolve-py-references ==0.1.0
10-
sphinxext-opengraph ==0.5.1
1+
sphinx
2+
sphinx-autodoc-typehints
3+
furo ==2022.04.07
4+
sphinx-copybutton
5+
sphinx-autobuild
6+
sphinx-reredirects
7+
sphinx-design
8+
sphinx-resolve-py-references
9+
sphinxext-opengraph

requirements/pkg-extras.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ uvicorn[standard] >=0.19.0
55
# extra=sanic
66
sanic >=21
77
sanic-cors
8+
uvicorn[standard] >=0.19.0
89

910
# extra=fastapi
1011
fastapi >=0.63.0

scripts/live_docs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ def main():
8181

8282
build_args, pre_build_commands = _get_build_args(args)
8383
builder = wrap_builder(
84-
get_builder(server.watcher, build_args, pre_build_commands=pre_build_commands)
84+
get_builder(
85+
server.watcher,
86+
build_args,
87+
host=args.host,
88+
port=args.port,
89+
pre_build_commands=pre_build_commands,
90+
)
8591
)
8692

8793
ignore_handler = _get_ignore_handler(args)
@@ -100,7 +106,7 @@ def main():
100106

101107
def opener():
102108
time.sleep(args.delay)
103-
webbrowser.open("http://%s:%s/index.html" % (args.host, 8000))
109+
webbrowser.open("http://%s:%s/index.html" % (args.host, args.port))
104110

105111
threading.Thread(target=opener, daemon=True).start()
106112

src/idom/backend/sanic.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ def configure(
5858

5959

6060
def create_development_app() -> Sanic:
61-
"""Return a :class:`Sanic` app instance in debug mode"""
62-
return Sanic(f"idom_development_app_{uuid4().hex}", Config())
61+
"""Return a :class:`Sanic` app instance in test mode"""
62+
Sanic.test_mode = True
63+
logger.warning("Sanic.test_mode is now active")
64+
app = Sanic(f"idom_development_app_{uuid4().hex}", Config())
65+
return app
6366

6467

6568
async def serve_development_app(

src/idom/web/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def resolve_module_exports_from_url(
5858
return set()
5959

6060
try:
61-
text = requests.get(url).text
61+
text = requests.get(url, headers={"User-Agent": _FAKE_USER_AGENT}).text
6262
except requests.exceptions.ConnectionError as error:
6363
reason = "" if error is None else " - {error.errno}"
6464
logger.warning("Did not resolve exports for url " + url + reason)
@@ -155,3 +155,8 @@ def _resolve_relative_url(base_url: str, rel_url: str) -> str:
155155
_JS_GENERAL_EXPORT_PATTERN = re.compile(
156156
r"(?:^|;|})\s*export(?=\s+|{)(.*?)(?=;|$)", re.MULTILINE
157157
)
158+
159+
# we fake the user agent to bypass some bot blockers
160+
_FAKE_USER_AGENT = (
161+
"Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion"
162+
)

0 commit comments

Comments
 (0)