Skip to content

Commit

Permalink
Merge branch 'main' into to-dict-from-arraylike
Browse files Browse the repository at this point in the history
  • Loading branch information
dangotbanned authored Jul 29, 2024
2 parents 04c292a + 7fe29d3 commit 7fe3929
Show file tree
Hide file tree
Showing 6 changed files with 3,202 additions and 3,684 deletions.
3,353 changes: 1,568 additions & 1,785 deletions altair/vegalite/v5/schema/channels.py

Large diffs are not rendered by default.

3,474 changes: 1,595 additions & 1,879 deletions altair/vegalite/v5/schema/core.py

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions doc/user_guide/customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -823,14 +823,6 @@ The preferred format of numbers, dates, and currencies varies by language and lo
Vega-Altair takes advantage of `D3's localization support`_ to make it easy to configure
the locale for your chart using the global ``alt.renderers.set_embed_options`` function.

.. altair-plot::
:output: none

import altair as alt
alt.renderers.set_embed_options(
format_locale=format_locale, time_format_locale=time_format_locale
)

Here ``format_locale`` and ``time_format_locale`` may either be D3 format dictionaries,
or strings with the names of pre-defined locales. For example, here we use the
Italian locale (named ``it-IT``) for both currencies and dates:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ dev = [
"hatch",
"ruff>=0.5.3",
"ibis-framework[polars]",
"ipython",
"ipython[kernel]",
"pandas>=0.25.3",
"pytest",
"pytest-cov",
"pytest-xdist[psutil]~=3.5",
"m2r",
"mistune",
"mypy",
"pandas-stubs",
"types-jsonschema",
Expand Down
14 changes: 4 additions & 10 deletions tools/generate_schema_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from typing import Final, Iterable, Literal, Iterator
from itertools import chain
from urllib import request
import m2r

sys.path.insert(0, str(Path.cwd()))
from tools.schemapi import codegen, CodeSnippet, SchemaInfo
Expand All @@ -23,6 +22,7 @@
rst_syntax_for_class,
indent_docstring,
ruff_write_lint_format_str,
rst_parse,
)


Expand Down Expand Up @@ -271,26 +271,20 @@ def _process_description(description: str) -> str:


def process_description(description: str) -> str:
# remove formatting from links
description = "".join(
[
reSpecial.sub("", d) if i % 2 else d
for i, d in enumerate(reLink.split(description))
]
) # remove formatting from links
description = m2r.convert(description)
description = description.replace(m2r.prolog, "")
description = description.replace(":raw-html-m2r:", ":raw-html:")
description = description.replace(r"\ ,", ",")
description = description.replace(r"\ ", " ")
# turn explicit references into anonymous references
description = description.replace(">`_", ">`__")
)
description = rst_parse(description)
# Some entries in the Vega-Lite schema miss the second occurence of '__'
description = description.replace("__Default value: ", "__Default value:__ ")
# Fixing ambiguous unicode, RUF001 produces RUF002 in docs
description = description.replace("’", "'") # noqa: RUF001 [RIGHT SINGLE QUOTATION MARK]
description = description.replace("–", "-") # noqa: RUF001 [EN DASH]
description = description.replace(" ", " ") # noqa: RUF001 [NO-BREAK SPACE]
description += "\n"
return description.strip()


Expand Down
33 changes: 33 additions & 0 deletions tools/schemapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
import urllib
from typing import Any, Final, Iterable, TYPE_CHECKING, Iterator, Sequence
from operator import itemgetter
from html import unescape

import mistune
from mistune.renderers.rst import RSTRenderer as _RSTRenderer

from tools.schemapi.schemapi import _resolve_references as resolve_references

if TYPE_CHECKING:
from mistune import BlockState
from typing_extensions import LiteralString
from pathlib import Path

Expand Down Expand Up @@ -652,6 +658,33 @@ def is_union_enum(self) -> bool:
return self.is_union() and all(el.is_enum() for el in self.anyOf)


class RSTRenderer(_RSTRenderer):
def __init__(self) -> None:
super().__init__()

def inline_html(self, token: dict[str, Any], state: BlockState) -> str:
html = token["raw"]
return rf"\ :raw-html:`{html}`\ "


class RSTParse(mistune.Markdown):
def __init__(
self,
renderer: mistune.BaseRenderer,
block: mistune.BlockParser | None = None,
inline: mistune.InlineParser | None = None,
plugins=None,
) -> None:
super().__init__(renderer, block, inline, plugins)

def __call__(self, s: str) -> str:
s = super().__call__(s)
return unescape(s).replace(r"\ ,", ",").replace(r"\ ", " ")


rst_parse: RSTParse = RSTParse(RSTRenderer())


def indent_docstring(
lines: list[str], indent_level: int, width: int = 100, lstrip=True
) -> str:
Expand Down

0 comments on commit 7fe3929

Please sign in to comment.