Skip to content

Commit

Permalink
feat: Adds Reader.open_markdown
Browse files Browse the repository at this point in the history
- Will be even more useful after merging vega/vega-datasets#663
- Thinking this is a fair tradeoff vs inlining the descriptions into `altair`
  - All the info is available and it is quicker than manually searching the headings in a browser
  • Loading branch information
dangotbanned committed Feb 1, 2025
1 parent 869d216 commit 7bb6f9e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions altair/datasets/_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,36 @@ def url(
msg = f"Expected 'str' but got {type(url).__name__!r}\nfrom {url!r}."
raise TypeError(msg)

# TODO: (Multiple)
# - Settle on a better name
# - Add method to `Loader`
# - Move docs to `Loader.{new name}`
def open_markdown(self, name: Dataset, /) -> None:
"""
Learn more about a dataset, opening `vega-datasets/datapackage.md`_ with the default browser.
Additional info *may* include: `description`_, `schema`_, `sources`_, `licenses`_.
.. _vega-datasets/datapackage.md:
https://github.com/vega/vega-datasets/blob/main/datapackage.md
.. _description:
https://datapackage.org/standard/data-resource/#description
.. _schema:
https://datapackage.org/standard/table-schema/#schema
.. _sources:
https://datapackage.org/standard/data-package/#sources
.. _licenses:
https://datapackage.org/standard/data-package/#licenses
"""
import webbrowser

from altair.utils import VERSIONS

ref = self._query(name).get_column("file_name").item(0).replace(".", "")
tag = VERSIONS["vega-datasets"]
url = f"https://github.com/vega/vega-datasets/blob/{tag}/datapackage.md#{ref}"
webbrowser.open(url)

@overload
def profile(self, *, show: Literal[False] = ...) -> _SupportProfile: ...

Expand Down

0 comments on commit 7bb6f9e

Please sign in to comment.