Skip to content

Commit

Permalink
Correct and enhance docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklinke committed Oct 12, 2024
1 parent d74e2bb commit 5a9ee85
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# django-owm

[![PyPI](https://img.shields.io/pypi/v/ kiecutter.project_name }}.svg)][pypi status]
[![PyPI](https://img.shields.io/pypi/v/django-own.svg)][pypi status]
[![Status](https://img.shields.io/pypi/status/django-owm.svg)][pypi status]
[![Python Version](https://img.shields.io/pypi/pyversions/django-owm)][pypi status]
[![License](https://img.shields.io/pypi/l/django-owm)][license]
Expand Down
34 changes: 0 additions & 34 deletions docs/autoreference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,6 @@

This document is an autogenerated reference for the `django_owm` package. It provides detailed information about the modules, classes, functions, and methods available in the package.

## Table of Contents

- [Autoreference](#autoreference)
- [Table of Contents](#table-of-contents)
- [django\_owm](#django_owm)
- [admin.py](#adminpy)
- [apps.py](#appspy)
- [app\_settings.py](#app_settingspy)
- [forms.py](#formspy)
- [management/commands/](#managementcommands)
- [create\_location.py](#create_locationpy)
- [delete\_location.py](#delete_locationpy)
- [list\_locations.py](#list_locationspy)
- [manual\_weather\_fetch.py](#manual_weather_fetchpy)
- [models/](#models)
- [abstract.py](#abstractpy)
- [base.py](#basepy)
- [concrete.py](#concretepy)
- [tasks.py](#taskspy)
- [urls.py](#urlspy)
- [utils/](#utils)
- [api.py](#apipy)
- [saving.py](#savingpy)
- [validators.py](#validatorspy)
- [views.py](#viewspy)


## django_owm

```{eval-rst}
.. automodule:: django_owm
:members:
```

## admin.py

```{eval-rst}
Expand Down
65 changes: 65 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,78 @@
"""Sphinx configuration."""

import inspect
import os
import sys

import django
from django.utils.html import strip_tags


sys.path.insert(0, os.path.abspath(".."))
os.environ["DJANGO_SETTINGS_MODULE"] = "example_project.settings"
django.setup()

project = "django-owm"
author = "Jack Linke"
copyright = "2024, Jack Linke"
extensions = [
"celery.contrib.sphinx",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx_click",
"myst_parser",
]
autodoc_typehints = "description"
html_theme = "furo"
autodoc_default_options = {
"members": True,
"special-members": "__init__",
"exclude-members": "__weakref__,Meta",
}
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"django": ("https://docs.djangoproject.com/en/stable/", "https://docs.djangoproject.com/en/stable/_objects/"),
}


def project_django_models(app, what, name, obj, options, lines): # pylint: disable=W0613 disable=R0913
"""Process Django models for autodoc.
From: https://djangosnippets.org/snippets/2533/
"""
from django.db import models # pylint: disable=C0415

# Only look at objects that inherit from Django's base model class
if inspect.isclass(obj) and issubclass(obj, models.Model):
# Grab the field list from the meta class
fields = obj._meta.get_fields() # pylint: disable=W0212

for field in fields:
# Decode and strip any html out of the field's help text
help_text = strip_tags(field.help_text)

# Decode and capitalize the verbose name, for use if there isn't
# any help text
verbose_name = field.verbose_name

if help_text:
# Add the model field to the end of the docstring as a param
# using the help text as the description
lines.append(f":param {field.attname}: {help_text}")
else:
# Add the model field to the end of the docstring as a param
# using the verbose name as the description
lines.append(f":param {field.attname}: {verbose_name}")

# Add the field's type to the docstring
lines.append(f":type {field.attname}: {field.__class__.__name__}")

# Return the extended docstring
return lines


def setup(app):
"""Register the Django model processor with Sphinx."""
app.connect("autodoc-process-docstring", project_django_models)
26 changes: 7 additions & 19 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@

This document provides a detailed overview of the components of `django-owm`.

## Table of Contents

- [Reference](#reference)
- [Table of Contents](#table-of-contents)
- [Models](#models)
- [Management Commands](#management-commands)
- [Utility Functions](#utility-functions)
- [App Settings](#app-settings)
- [Example Settings Dictionary](#example-settings-dictionary)
- [Views](#views)
- [Admin](#admin)

### Models
## Models

The `django-owm` app includes several abstract models that developers can use or extend for storing weather data:

Expand All @@ -29,7 +17,7 @@ The `django-owm` app includes several abstract models that developers can use or

These models are all abstract, allowing developers to customize their own concrete versions as needed.

### Management Commands
## Management Commands

The app provides several management commands to interact with the weather data models:

Expand Down Expand Up @@ -57,15 +45,15 @@ The app provides several management commands to interact with the weather data m

These commands help developers easily manage the locations for which weather data is collected.

### Utility Functions
## Utility Functions

The `utils` module provides various utility functions to interact with the OpenWeatherMap API and save data:

- **API Interaction**: Functions such as `make_api_call` for making requests to OpenWeatherMap, and `check_api_limits` to enforce API rate limits.
- **Data Saving**: Functions such as `save_weather_data`, `save_current_weather`, `save_hourly_weather`, etc., for storing weather data in the database.
- **Error Logging**: Function `save_error_log` to log errors encountered when fetching weather data.

### App Settings
## App Settings

The settings for the `django-owm` app are defined in `app_settings.py`, allowing flexibility for customization:

Expand Down Expand Up @@ -119,7 +107,7 @@ The settings for the `django-owm` app are defined in `app_settings.py`, allowing
- **Example**: `OWM_USE_UUID = True`
- **Why Set**: Developers may choose to use UUIDs for models to enhance data uniqueness and security, particularly in distributed systems.

#### Example Settings Dictionary
### Example Settings Dictionary

```python
DJANGO_OWM = {
Expand Down Expand Up @@ -147,7 +135,7 @@ DJANGO_OWM = {

These settings provide a flexible and extensible approach to managing the app's configuration, allowing developers to tailor the behavior and data models of the `django-owm` app to meet the needs of their specific project.

### Views
## Views

The app provides several function-based views for displaying weather data:

Expand All @@ -163,7 +151,7 @@ The app provides several function-based views for displaying weather data:

These views are designed to be easily customizable and integrate seamlessly with Django templates.

### Admin
## Admin

The app provides built-in Django admin support for the weather data models, including:

Expand Down

0 comments on commit 5a9ee85

Please sign in to comment.