Skip to content

Commit

Permalink
docs(sphinx): restructure documentation and update configuration
Browse files Browse the repository at this point in the history
This commit significantly restructures the documentation and updates the Sphinx configuration. Key changes include:

 • Reorganize documentation files and structure
 • Add new RST files for CLI usage, introduction, and API reference
 • Update Sphinx configuration with new extensions and theme settings
 • Remove old documentation files
 • Update pyproject.toml with new documentation dependencies
  • Loading branch information
bendikrb committed Sep 26, 2024
1 parent 63f3bd8 commit c16bf50
Show file tree
Hide file tree
Showing 22 changed files with 747 additions and 50 deletions.
21 changes: 0 additions & 21 deletions docs/api.rst

This file was deleted.

13 changes: 0 additions & 13 deletions docs/conf.py

This file was deleted.

8 changes: 0 additions & 8 deletions docs/index.rst

This file was deleted.

66 changes: 66 additions & 0 deletions docs/source/cli.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
CLI Usage
=========

The ``nrk-psapi`` library includes a command-line interface (CLI) script to interact with the API. Below are examples of how to use the CLI script.


Browse Podcasts
---------------

To browse podcasts by a specific letter:

.. code-block:: bash
poetry run nrk browse A
Get Podcast
-----------

To get details of a specific podcast:

.. code-block:: bash
poetry run nrk podcast <podcast_id>
To get episodes of a specific podcast:

.. code-block:: bash
poetry run nrk podcast <podcast_id> --episodes
Get Episode
-----------

To get details of a specific episode:

.. code-block:: bash
poetry run nrk episode <podcast_id> <episode_id>
To get metadata of a specific episode:

.. code-block:: bash
poetry run nrk episode <podcast_id> <episode_id> --metadata
Build RSS Feed
--------------

To build a RSS feed for a specific podcast:

.. code-block:: bash
poetry run nrk rss <podcast_id> <output_path>
Search
------

To search for podcasts or other content:

.. code-block:: bash
poetry run nrk search <query>
37 changes: 37 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from importlib.metadata import Distribution
from pathlib import Path
import sys

import sphinx_book_theme

sys.path.insert(0, Path("../").resolve().as_posix())

project = 'NRK Podcast API'
author = '@bendikrb'
release = Distribution.from_name("nrk_psapi").version

html_theme = "sphinx_book_theme"
html_theme_path = [sphinx_book_theme.get_html_theme_path()]
html_theme_options = {
"repository_url": "https://github.com/bendikrb/nrk-psapi",
"use_repository_button": True,
}

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autodoc.typehints",
"sphinx.ext.viewcode",
"sphinx_autodoc_typehints",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx.ext.autosectionlabel",
"enum_tools.autoenum",
]
templates_path = ['_templates']
html_static_path = ["_static"]
intersphinx_mapping = {"python": ("http://docs.python.org/3", None)}

autodoc_typehints = "description"
autodoc_typehints_description_target = "documented_params"

source_suffix = '.rst'
19 changes: 19 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Welcome to NRK Podcast API
==========================

.. toctree::
:maxdepth: 2
:caption: Contents:

introduction.rst

cli.rst

reference.rst


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
47 changes: 47 additions & 0 deletions docs/source/introduction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Introduction
============

The ``NrkPodcastAPI`` library provides an asynchronous interface to interact with the NRK Podcast API. It allows users to fetch podcast data, episodes, series, and more using a variety of methods.

Requirements
------------

Rich requires Python 3.11 and above.


Installation
------------

To install the library, use pip:

.. code-block:: bash
pip install nrk-psapi
Usage
-----

To use the ``NrkPodcastAPI``, you need to create an instance of the class and call its methods asynchronously.

Example:

.. code-block:: python
import asyncio
from nrk_psapi import NrkPodcastAPI
async def main():
async with NrkPodcastAPI(user_agent="YourApp/1.0") as api:
podcasts = await api.get_all_podcasts()
for podcast in podcasts:
print(podcast.title)
asyncio.run(main())
Logging
-------

The library uses a logger named ``nrk_psapi`` to log debug information. You can configure this logger to capture logs as needed.

19 changes: 19 additions & 0 deletions docs/source/reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Reference
=========

.. toctree::
:maxdepth: 2

reference/api.rst
reference/caching.rst
reference/utils.rst
reference/rss.rst

reference/catalog.rst
reference/channels.rst
reference/common.rst
reference/metadata.rst
reference/pages.rst
reference/playback.rst
reference/recommendations.rst
reference/search.rst
7 changes: 7 additions & 0 deletions docs/source/reference/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Client
======

.. autoclass:: nrk_psapi.api.NrkPodcastAPI
:members:
:undoc-members:
:exclude-members: close, request_header
5 changes: 5 additions & 0 deletions docs/source/reference/caching.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Caching
=======

.. automodule:: nrk_psapi.caching
:members:
6 changes: 6 additions & 0 deletions docs/source/reference/catalog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Catalog
=======

.. automodule:: nrk_psapi.models.catalog
:members: Availability, Contributor, Episode, EpisodeContext, EpisodeType, Image, IndexPoint, Link, Podcast, PodcastSequential, PodcastSeries, PodcastStandard, PodcastType, PodcastUmbrella, Program, ProgramInformation, ProgramInformationDetails, Season, SeasonBase, SeasonDisplayType, SeasonEmbedded, Series, SeriesType, Titles, UsageRights
:show-inheritance:
5 changes: 5 additions & 0 deletions docs/source/reference/channels.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Channels
========

.. automodule:: nrk_psapi.models.channels
:members: Channel, ChannelEntry, ChannelImage, ChannelType, DistrictChannel
5 changes: 5 additions & 0 deletions docs/source/reference/common.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Common
======

.. automodule:: nrk_psapi.models.common
:members: IpCheck
5 changes: 5 additions & 0 deletions docs/source/reference/metadata.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Metadata
========

.. automodule:: nrk_psapi.models.metadata
:members: Manifest, PodcastEpisodeMetadata, PodcastMetadata, PodcastMetadataEmbedded, Preplay
5 changes: 5 additions & 0 deletions docs/source/reference/pages.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Pages
=====

.. automodule:: nrk_psapi.models.pages
:members: ChannelPlug, Curated, CuratedPodcast, CuratedSection, EpisodePlug, Included, IncludedSection, LinkPlug, Page, PageListItem, PagePlug, Pages, PlaceholderSection, Plug, PluggedChannel, PluggedEpisode, PluggedPodcast, PluggedPodcastEpisode, PluggedPodcastSeason, PluggedSeries, PluggedStandaloneProgram, PlugType, PodcastEpisodePlug, PodcastPlug, PodcastSeasonPlug, Section, SeriesPlug, StandaloneProgramPlug
5 changes: 5 additions & 0 deletions docs/source/reference/playback.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Playback
========

.. automodule:: nrk_psapi.models.playback
:members: AvailabilityDetailed, Playable, PodcastManifest
5 changes: 5 additions & 0 deletions docs/source/reference/recommendations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Recommendations
===============

.. automodule:: nrk_psapi.models.recommendations
:members: Recommendation
7 changes: 7 additions & 0 deletions docs/source/reference/rss.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RSS
===

.. autoclass:: nrk_psapi.rss.NrkPodcastFeed
:members:
:undoc-members:
:exclude-members: api, base_url
5 changes: 5 additions & 0 deletions docs/source/reference/search.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Search
======

.. automodule:: nrk_psapi.models.search
:members: CategoriesResponse, LetterListItem, PodcastSearchResponse, SearchedSeries, SearchResponse, SearchResponseResultCategory, SearchResponseResultChannel, SearchResponseResultCustomSeason, SearchResponseResultCustomSeasonEpisode, SearchResponseResultEpisode, SearchResponseResultPodcast, SearchResponseResultSeries, SearchResponseResultSeriesEpisode, SearchResultType, SeriesListItem
5 changes: 5 additions & 0 deletions docs/source/reference/utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Utilities
=========

.. automodule:: nrk_psapi.utils
:members:
Loading

0 comments on commit c16bf50

Please sign in to comment.