Skip to content

fix tests + upgrade doc dependencies #862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2023
Merged
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
2 changes: 1 addition & 1 deletion docs/source/_custom_js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions docs/source/_exts/async_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@


test_template = """
import asyncio as __asyncio
import asyncio as __test_template_asyncio

async def __run():
async def __test_template__main():

{test}

globals().update(locals())

loop = __asyncio.get_event_loop()
loop.run_until_complete(__run())
__test_template_asyncio.run(__test_template__main())
"""


Expand Down
2 changes: 1 addition & 1 deletion docs/source/_exts/idom_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def run(self):
[],
{},
_make_tab_items(labeled_tab_items),
self.lineno - 1,
self.lineno - 2,
self.content_offset,
"",
self.state,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/_exts/idom_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run(self):
<div>
<div
id="{container_id}"
class="interactive widget-container center-content"
class="interactive widget-container"
style="margin-bottom: {self.options.get("margin", 0)}px;"
/>
<script type="module">
Expand Down
5 changes: 0 additions & 5 deletions docs/source/_static/css/idom-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
width: 100%;
}

.center-content {
display: flex;
align-items: center;
justify-content: center;
}
.enable-widget-button {
padding: 10px;
color: #ffffff !important;
Expand Down
3 changes: 0 additions & 3 deletions docs/source/_static/css/set-color-scheme.css

This file was deleted.

2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
7 changes: 3 additions & 4 deletions docs/source/guides/getting-started/installing-idom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ ensure the modifications you've made are backwards compatible. If you want to ad
feature to IDOM you should write your own test that validates its behavior.

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

.. card::
:link: /about/contributor-guide
Expand Down
19 changes: 9 additions & 10 deletions requirements/build-docs.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
sphinx ==4.2.0
sphinx-autodoc-typehints ==1.7.0
furo ==2021.10.09
setuptools_scm
sphinx-copybutton ==0.3.0
sphinx-autobuild ==2020.9.1
sphinx-reredirects ==0.0.1
sphinx-design ==0.0.13
sphinx-resolve-py-references ==0.1.0
sphinxext-opengraph ==0.5.1
sphinx
sphinx-autodoc-typehints
furo ==2022.04.07
sphinx-copybutton
sphinx-autobuild
sphinx-reredirects
sphinx-design
sphinx-resolve-py-references
sphinxext-opengraph
1 change: 1 addition & 0 deletions requirements/pkg-extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ uvicorn[standard] >=0.19.0
# extra=sanic
sanic >=21
sanic-cors
uvicorn[standard] >=0.19.0

# extra=fastapi
fastapi >=0.63.0
Expand Down
10 changes: 8 additions & 2 deletions scripts/live_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ def main():

build_args, pre_build_commands = _get_build_args(args)
builder = wrap_builder(
get_builder(server.watcher, build_args, pre_build_commands=pre_build_commands)
get_builder(
server.watcher,
build_args,
host=args.host,
port=args.port,
pre_build_commands=pre_build_commands,
)
)

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

def opener():
time.sleep(args.delay)
webbrowser.open("http://%s:%s/index.html" % (args.host, 8000))
webbrowser.open("http://%s:%s/index.html" % (args.host, args.port))

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

Expand Down
7 changes: 5 additions & 2 deletions src/idom/backend/sanic.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ def configure(


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


async def serve_development_app(
Expand Down
7 changes: 6 additions & 1 deletion src/idom/web/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def resolve_module_exports_from_url(
return set()

try:
text = requests.get(url).text
text = requests.get(url, headers={"User-Agent": _FAKE_USER_AGENT}).text
except requests.exceptions.ConnectionError as error:
reason = "" if error is None else " - {error.errno}"
logger.warning("Did not resolve exports for url " + url + reason)
Expand Down Expand Up @@ -155,3 +155,8 @@ def _resolve_relative_url(base_url: str, rel_url: str) -> str:
_JS_GENERAL_EXPORT_PATTERN = re.compile(
r"(?:^|;|})\s*export(?=\s+|{)(.*?)(?=;|$)", re.MULTILINE
)

# we fake the user agent to bypass some bot blockers
_FAKE_USER_AGENT = (
"Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion"
)