Skip to content

Commit

Permalink
Fix two bugs + cards from website (#263)
Browse files Browse the repository at this point in the history
* Update ruff and add cards

* Fix hover over table color

* Fix cards
  • Loading branch information
nabobalis authored Aug 6, 2024
1 parent 95bac35 commit f92e892
Show file tree
Hide file tree
Showing 20 changed files with 333 additions and 113 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/lighthouse.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
RTD_AUTH_TOKEN: ${{ secrets.RTD_AUTH_TOKEN }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run: |
python rebuild_all_rtd.py
python tools/rebuild_all_rtd.py
http POST https://api.netlify.com/api/v1/sites/1ba3a6d4-f1ee-4524-bbec-3edc04720a48/builds "Authorization: Bearer $NETLIFY_AUTH_TOKEN"
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ci:
autoupdate_schedule: "quarterly"
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.5.1"
rev: "v0.5.6"
hooks:
- id: ruff
args: ["--fix", "--unsafe-fixes"]
Expand Down Expand Up @@ -42,6 +42,6 @@ repos:
args: ["--fix=lf"]
- id: trailing-whitespace
- repo: https://github.com/crate-ci/typos
rev: v1.23.1
rev: v1.23.6
hooks:
- id: typos
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
exclude rebuild_all_rtd.py
exclude tox.ini
exclude .gitignore
exclude .pre-commit-config.yaml
exclude .stylelintrc

prune .circleci/
prune .github/
prune docs/
prune examples/
prune tools/

recursive-include src/sunpy_sphinx_theme/sunpy/ *
Binary file added docs/_static/img/Stuart-Mumford.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions docs/cards.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
================
Cards and Tables
================

This page covers the cards and tables that are used in the website.

Cards
******

.. custom-card:: Stuart Mumford
:img_name: Stuart-Mumford.png
:github: cadair
:title: Lead Developer
:aff_name: Sheffield University
:aff_link: https://www.sheffield.ac.uk/
:date: 17 March 2014

Stuart Mumford is the Python developer for the Daniel K. Inouye Solar Telescope Data Centre. He obtained a PhD in Numerical solar physics from Sheffield University in 2016, prior to his PhD he obtained a first class MPhys degree in Physics with Planetary and Space Physics from The University of Wales Aberystwyth, during which he spent 5 months studying at UNIS on Svalbard in the high arctic.

Tables
******

.. list-table::
:widths: 20, 80

* - **sunpy core**
- The core package for solar physics in Python.

`Documentation <https://docs.sunpy.org/>`__, `Source code <https://github.com/sunpy/sunpy>`__

|package_general| |integration_full| |docs_extensive| |tests_excellent| |duplication_none| |community_excellent| |dev_stable|

**Maintainer**: `The SunPy Project`_

Version reviewed: `v1.1.4 <https://github.com/sunpy/sunpy/releases/tag/v1.1.4>`__

.. _The SunPy Project: https://sunpy.org/about/roles
.. |package_general| image:: https://img.shields.io/badge/Functionality-General_Package-brightgreen.svg
.. |integration_full| image:: https://img.shields.io/badge/Integration-Full-brightgreen.svg
.. |docs_extensive| image:: https://img.shields.io/badge/Documentation-Extensive-brightgreen.svg
.. |tests_excellent| image:: https://img.shields.io/badge/Testing-Excellent-brightgreen.svg
.. |duplication_none| image:: https://img.shields.io/badge/Duplication-None-brightgreen.svg
.. |community_excellent| image:: https://img.shields.io/badge/Community-Excellent-brightgreen.svg
.. |dev_stable| image:: https://img.shields.io/badge/Development_Status-Stable-brightgreen.svg
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pathlib import Path

from sphinx_gallery.sorting import ExplicitOrder
from sunpy_sphinx_theme import SVG_ICON
from sunpy_sphinx_theme import SVG_ICON, _sunpy_static_path

# Add the test package to the path so we can import it for automodapi
sys.path.append(Path().absolute().as_posix())
Expand Down Expand Up @@ -67,6 +67,8 @@
"reproject": ("https://reproject.readthedocs.io/en/stable/", None),
}
html_theme = "sunpy"
html_static_path = [str(_sunpy_static_path), "_static"]
html_extra_path = ["_static/img"]
html_theme_options = {
"footer_links": [
("Google", "https://google.com", 3),
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The core changes between this theme and the `pydata-sphinx-theme` are:
customizing
colors
web-components
cards

.. grid-item-card::
:class-card: card
Expand Down
6 changes: 6 additions & 0 deletions docs/test_package/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
"""
Test package for the documentation.
Uses code stolen from the internet.
"""

from .animals import * # noqa: F403
from .timerange import * # noqa: F403
13 changes: 4 additions & 9 deletions docs/test_package/animals.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Animal:

says_str = "A {name} says {sound}"

def __init__(self, name, sound, num_legs=5):
def __init__(self, name, sound, num_legs=5) -> None:
"""
Parameters
----------
Expand All @@ -61,7 +61,7 @@ def __init__(self, name, sound, num_legs=5):
self.sound = sound
self.num_legs = num_legs

def says(self, sound=None):
def says(self, sound=None) -> None:
"""
Prints what the animals name is and what sound it makes.
Expand All @@ -87,11 +87,8 @@ def says(self, sound=None):
msg = "Silent Animals are not supported!"
raise NotImplementedError(msg)

out_sound = self.sound if sound is None else sound
print(self.says_str.format(name=self.name, sound=out_sound))


def function():
def function() -> None:
"""
Prints what the animals name is and what sound it makes.
Expand Down Expand Up @@ -132,10 +129,9 @@ def function():
----------
* `A URL. <www.sunpy.org>`__
"""
print("A SOUND")


def a_really_long_function_name_just_to_see_what_happens():
def a_really_long_function_name_just_to_see_what_happens() -> None:
"""
Prints what the animals name is and what sound it makes.
Expand Down Expand Up @@ -176,4 +172,3 @@ def a_really_long_function_name_just_to_see_what_happens():
----------
* `A URL. <www.sunpy.org>`__
"""
print("A SOUND")
8 changes: 4 additions & 4 deletions docs/test_package/timerange.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TimeRange:
<BLANKLINE>
"""

def __init__(self, a, b=None, format=None): # NOQA: A002
def __init__(self, a, b=None, format=None) -> None: # NOQA: A002
# If a is a TimeRange object, copy attributes to new instance.
self._t1 = None
self._t2 = None
Expand Down Expand Up @@ -238,7 +238,7 @@ def __ne__(self, other):

return NotImplemented

def __repr__(self):
def __repr__(self) -> str:
"""
Returns a human-readable representation of `sunpy.time.TimeRange`.
"""
Expand Down Expand Up @@ -385,7 +385,7 @@ def previous(self):

return self

def extend(self, dt_start, dt_end):
def extend(self, dt_start, dt_end) -> None:
"""
Extend the time range forwards and backwards.
Expand All @@ -409,7 +409,7 @@ def get_dates(self):
]

@add_common_docstring(**_variables_for_parse_time_docstring())
def __contains__(self, time):
def __contains__(self, time) -> bool:
"""
Checks whether the given time lies within this range. Both limits are
inclusive (i.e., ``__contains__(t1)`` and ``__contains__(t2)`` always
Expand Down
2 changes: 1 addition & 1 deletion examples/example_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# Comments in comment blocks remain nested in the text.


def dummy():
def dummy() -> None:
"""
Dummy function to make sure docstrings don't get rendered as text.
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/section/example_template_subsection.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
# Comments in comment blocks remain nested in the text.


def dummy():
def dummy() -> None:
"""
Dummy function to make sure docstrings don't get rendered as text.
"""
Expand Down
98 changes: 44 additions & 54 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,74 +1,64 @@
# Allow unused variables when underscore-prefixed.
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
target-version = "py39"
target-version = "py310"
line-length = 120
exclude=[
".git,",
extend-exclude=[
"__pycache__",
"build",
"tools/**",
]
lint.select = [
"A",
"ARG",
"ASYNC",
"B",
"BLE",
"C4",
"COM",
"DTZ",
"E",
"EM",
"ERA",
"EXE",
"F",
"FBT",
"FLY",
"G",
"I",
"ICN",
"INP",
"INT",
"ISC",
"LOG",
"NPY",
"PERF",
"PGH",
"PIE",
"PLE",
"PT",
"PTH",
"PYI",
"Q",
"RET",
"RSE",
"RUF",
"SIM",
"SLF",
"SLOT",
"T10",
"T20",
"TCH",
"TID",
"TRIO",
"TRY",
"UP",
"W",
"YTT",
"ALL",
]
lint.extend-ignore = [
"ANN001", # Missing type annotation for function argument
"ANN002", # Missing type annotation for variable
"ANN003", # Missing type annotation for keyword
"ANN201", # Missing return type annotation for public function
"ANN202", # Missing return type annotation for private function
"ANN204", # Missing return type annotation for special method
"ANN205", # Missing return type annotation for staticmethod
"ANN206", # Missing return type annotation for classmethod
"COM812", # May cause conflicts when used with the formatter
"E501", # Line too long
"ISC001", # May cause conflicts when used with the formatter
"T201", # Print statements
"D200", # One-line docstring should fit on one line
"D205", # 1 blank line required between summary line and description
"D400", # First line should end with a period
"D401", # First line should be in imperative mood
"D404", # First word of the docstring should not be "This"
"E501", # Line too long
"FIX002", # Line contains TODO, consider resolving the issue
"ISC001", # May cause conflicts when used with the formatter
"PLR2004", # Magic value used in comparison
"TD002", # Missing author in TODO
"TD003", # Missing issue link on the line following this TODO
]

[lint.per-file-ignores]
"examples/*.py" = [
"INP001", # Part of an implicit namespace package
"B018", # Not print but display
"D400", # First line should end with a period, question mark, or exclamation point
"ERA001", # Commented out code
"INP001", # Implicit namespace package
"T201", # Use print
]
"docs/conf.py" = [
"INP001", # Part of an implicit namespace package
"D100", # Missing docstring in public module
"INP001", # conf.py is part of an implicit namespace package
]
"setup.py" = [
"D100", # Missing docstring in public module
]
"test_*.py" = [
"D100", # Missing docstring in public module
"D103", # Missing docstring in public function
"N806", # in function should be lowercase
"S101", # Use of `assert` detected
]
"sunpy_soar/version.py" = [
"D100", # Missing docstring in public module
]
"sunpy_soar/conftest.py" = [
"D100", # Missing docstring in public module
]

[lint.pydocstyle]
Expand Down
8 changes: 6 additions & 2 deletions src/sunpy_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from pydata_sphinx_theme import utils
from sphinx.application import Sphinx

from .cards import Card, _Card, depart_card_node, visit_card_node

__all__ = ["get_html_theme_path", "ON_RTD", "PNG_ICON", "SVG_ICON"]


Expand Down Expand Up @@ -61,7 +63,7 @@ def default_navbar():
]


def update_config(app):
def update_config(app) -> None:
"""
Update config with new default values and handle deprecated keys.
"""
Expand Down Expand Up @@ -139,7 +141,9 @@ def setup(app: Sphinx):
theme_dir = get_html_theme_path()
app.add_html_theme("sunpy", theme_dir)
app.add_css_file("sunpy_style.css", priority=600)

app.add_css_file("sunpy_cards.css", priority=600)
app.add_directive("custom-card", Card)
app.add_node(_Card, html=(visit_card_node, depart_card_node))
app.connect("builder-inited", update_config)
app.connect("html-page-context", update_html_context)

Expand Down
Loading

0 comments on commit f92e892

Please sign in to comment.