Skip to content

Commit ef78f19

Browse files
committed
doc: reword documentation
1 parent 5c68640 commit ef78f19

13 files changed

+139
-112
lines changed

README.md

+19-13
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,53 @@
1111

1212
A free and asynchronous weather Python API wrapper made in Python, for Python.
1313

14-
## Installation
14+
## Getting started
15+
16+
Run the following command in your terminal:
1517

1618
```console
17-
pip install python-weather
19+
$ pip install python-weather
1820
```
1921

2022
## Example
2123

2224
For more information, please read the [documentation](https://python-weather.readthedocs.io/en/latest/).
2325

2426
```py
25-
# import the module
27+
# Import the module.
2628
import python_weather
2729

2830
import asyncio
2931
import os
3032

31-
async def getweather() -> None:
32-
# declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)
33+
34+
async def main() -> None:
35+
36+
# Declare the client. The measuring unit used defaults to the metric system (celcius, km/h, etc.)
3337
async with python_weather.Client(unit=python_weather.IMPERIAL) as client:
34-
# fetch a weather forecast from a city
38+
39+
# Fetch a weather forecast from a city.
3540
weather = await client.get('New York')
3641

37-
# returns the current day's forecast temperature (int)
42+
# Fetch the temperature for today.
3843
print(weather.temperature)
3944

40-
# get the weather forecast for a few days
45+
# Fetch weather forecast for upcoming days.
4146
for daily in weather:
4247
print(daily)
43-
44-
# hourly forecasts
48+
49+
# Each daily forecast has their own hourly forecasts.
4550
for hourly in daily:
4651
print(f' --> {hourly!r}')
4752

4853
if __name__ == '__main__':
49-
# see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
50-
# for more details
54+
55+
# See https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
56+
# for more details.
5157
if os.name == 'nt':
5258
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
5359

54-
asyncio.run(getweather())
60+
asyncio.run(main())
5561
```
5662

5763
## Data source

docs/changelog.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class Row:
7-
__slots__: Tuple[str, ...] = ('header_name', 'rows', 'character_length')
7+
__slots__: tuple[str, ...] = ('header_name', 'rows', 'character_length')
88

99
def __init__(self, header_name: str):
1010
self.header_name = header_name
@@ -25,7 +25,7 @@ def render(self, text: str) -> str:
2525
CHANGE_EMOJIS = {'add': chr(129001), 'fix': chr(128998), 'rem': chr(128997)}
2626

2727

28-
def render_lines(rows: List[Row], character: str = '-') -> str:
28+
def render_lines(rows: list[Row], character: str = '-') -> str:
2929
output = f'+{character}'
3030
last_idx = len(rows) - 1
3131

@@ -38,7 +38,7 @@ def render_lines(rows: List[Row], character: str = '-') -> str:
3838
return output
3939

4040

41-
def render_contents(rows: List[Row], idx: int) -> str:
41+
def render_contents(rows: list[Row], idx: int) -> str:
4242
max_row_lines = max(map(lambda row: len(row.rows[idx].splitlines()), rows))
4343
output = ''
4444

@@ -57,7 +57,7 @@ def render_contents(rows: List[Row], idx: int) -> str:
5757
return output[:-1]
5858

5959

60-
def render(rows: List[Row]) -> str:
60+
def render(rows: list[Row]) -> str:
6161
output = f'{render_lines(rows)}\n'
6262

6363
for row in rows:

docs/conf.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
import os
33
import re
44

5+
6+
sys.path.insert(0, os.path.join(os.getcwd(), '..', 'python_weather'))
57
sys.path.insert(0, os.path.abspath('..'))
68

9+
from version import VERSION
10+
11+
712
project = 'python-weather'
813
author = 'null8626'
914

1015
copyright = ''
1116
with open('../LICENSE', 'r') as f:
1217
copyright = re.search(r'[\d\-]+ null8626', f.read()).group()
1318

14-
version = ''
15-
with open('../python_weather/__init__.py', 'r') as f:
16-
version = re.search(
17-
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE
18-
).group(1)
19-
19+
version = VERSION
2020
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx_reredirects']
2121

2222
intersphinx_mapping = {

docs/index.rst

+18-12
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ python-weather_
2323

2424
A free and asynchronous weather Python API wrapper made in Python, for Python.
2525

26-
Installation
27-
------------
26+
Getting started
27+
---------------
28+
29+
Run the following command in your terminal:
2830

2931
.. code-block:: console
3032
@@ -35,36 +37,40 @@ Example
3537

3638
.. code-block:: python
3739
38-
# import the module
40+
# Import the module.
3941
import python_weather
4042
4143
import asyncio
4244
import os
4345
44-
async def getweather() -> None:
45-
# declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)
46+
47+
async def main() -> None:
48+
49+
# Declare the client. The measuring unit used defaults to the metric system (celcius, km/h, etc.)
4650
async with python_weather.Client(unit=python_weather.IMPERIAL) as client:
47-
# fetch a weather forecast from a city
51+
52+
# Fetch a weather forecast from a city.
4853
weather = await client.get('New York')
4954
50-
# returns the current day's forecast temperature (int)
55+
# Fetch the temperature for today.
5156
print(weather.temperature)
5257
53-
# get the weather forecast for a few days
58+
# Fetch weather forecast for upcoming days.
5459
for daily in weather:
5560
print(daily)
5661
57-
# hourly forecasts
62+
# Each daily forecast has their own hourly forecasts.
5863
for hourly in daily:
5964
print(f' --> {hourly!r}')
6065
6166
if __name__ == '__main__':
62-
# see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
63-
# for more details
67+
68+
# See https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
69+
# for more details.
6470
if os.name == 'nt':
6571
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
6672
67-
asyncio.run(getweather())
73+
asyncio.run(main())
6874
6975
Data source
7076
___________

python_weather/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
from .enums import HeatIndex, Kind, Locale, Phase, UltraViolet, WindDirection
2626
from .constants import METRIC, IMPERIAL
2727
from .errors import Error, RequestError
28+
from .version import VERSION
2829
from .client import Client
2930

31+
3032
__title__ = 'python-weather'
3133
__author__ = 'null8626'
3234
__license__ = 'MIT'
3335
__copyright__ = 'Copyright (c) 2021-2025 null8626'
34-
__version__ = '2.0.7'
36+
__version__ = VERSION
3537
__all__ = (
3638
'METRIC',
3739
'IMPERIAL',
@@ -43,5 +45,6 @@
4345
'Locale',
4446
'Phase',
4547
'UltraViolet',
48+
'VERSION',
4649
'WindDirection',
4750
)

python_weather/base.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,32 @@
2222
SOFTWARE.
2323
"""
2424

25-
from typing import Tuple
26-
27-
from .errors import Error
2825
from .enums import WindDirection, Kind, Locale, UltraViolet
2926
from .constants import _Unit
27+
from .errors import Error
3028

3129

3230
class CustomizableBase:
33-
__slots__: Tuple[str, ...] = ('__unit', '__locale')
31+
__slots__: tuple[str, ...] = ('__unit', '__locale')
3432

3533
def __init__(self, unit: _Unit, locale: Locale):
3634
self.unit = unit
3735
self.locale = locale
3836

3937
@property
4038
def unit(self) -> _Unit:
41-
"""The measuring unit used to display information in this object."""
39+
"""The measuring unit used."""
4240

4341
return self.__unit
4442

4543
@unit.setter
4644
def unit(self, to: _Unit) -> None:
4745
"""
48-
Sets the default measuring unit used to display information in this object.
46+
Sets the default measuring unit used.
4947
50-
:param to: The new default measuring unit to be used to display information in this object. Must be either ``METRIC`` or ``IMPERIAL``.
51-
:exception Error: If the ``to`` argument is not either ``METRIC`` or ``IMPERIAL``.
48+
:param to: The new default measuring unit to be used.
49+
50+
:exception Error: ``to`` is not either ``METRIC`` or ``IMPERIAL``.
5251
"""
5352

5453
if not isinstance(to, _Unit):
@@ -58,18 +57,19 @@ def unit(self, to: _Unit) -> None:
5857

5958
@property
6059
def locale(self) -> Locale:
61-
"""The localization used to display information in this object."""
60+
"""The localization used."""
6261

6362
return self.__locale
6463

6564
@locale.setter
6665
def locale(self, to: Locale) -> None:
6766
"""
68-
Sets the default localization used to display information in this object.
67+
Sets the default localization used.
6968
70-
:param to: The new :class:`.Locale` to be used to display information in this object.
69+
:param to: The new :class:`.Locale` to be used.
7170
:type to: :class:`.Locale`
72-
:exception Error: If the ``to`` argument is not a part of the :class:`.Locale` enum.
71+
72+
:exception Error: ``to`` is not a part of the :class:`.Locale` enum.
7373
"""
7474

7575
if not isinstance(to, Locale):
@@ -79,7 +79,7 @@ def locale(self, to: Locale) -> None:
7979

8080

8181
class BaseForecast:
82-
__slots__: Tuple[str, ...] = (
82+
__slots__: tuple[str, ...] = (
8383
'ultraviolet',
8484
'humidity',
8585
'wind_direction',
@@ -94,7 +94,7 @@ class BaseForecast:
9494
)
9595

9696
ultraviolet: UltraViolet
97-
"""The ultra-violet (UV) index."""
97+
"""The ultra-violet index."""
9898

9999
humidity: int
100100
"""The humidity value in percent."""
@@ -106,10 +106,10 @@ class BaseForecast:
106106
"""The kind of the forecast."""
107107

108108
feels_like: int
109-
"""What it felt like, in celcius or fahrenheit."""
109+
"""What it felt like in either celcius or fahrenheit."""
110110

111111
temperature: int
112-
"""The temperature in either celcius or Fahrenheit."""
112+
"""The temperature in either celcius or fahrenheit."""
113113

114114
precipitation: float
115115
"""The precipitation in either millimeters or inches."""
@@ -124,7 +124,7 @@ class BaseForecast:
124124
"""The wind speeds in either kilometers/hour or miles/hour."""
125125

126126
description: str
127-
"""The description regarding the forecast. This can be localized in different languages depending on the localization used."""
127+
"""The description regarding the forecast depending on the localization used."""
128128

129129
def __init__(self, json: dict, unit: _Unit, locale: Locale):
130130
description = (

0 commit comments

Comments
 (0)