From af04fa4ac067489558cc090fa93613e9d165052e Mon Sep 17 00:00:00 2001 From: sigma67 <16363825+sigma67@users.noreply.github.com> Date: Fri, 17 Jan 2025 20:17:04 +0100 Subject: [PATCH] Fix 720 (#726) * update dev-dependencies * fix INP001 * rework docs (closes #720) * update .readthedocs.yml --- .gitignore | 1 + .readthedocs.yml | 3 +++ docs/Makefile | 1 + docs/make.bat | 1 + docs/source/_static/css/custom.css | 19 ++++++++++++++ docs/source/_static/style.css | 3 --- docs/source/conf.py | 8 +++++- docs/source/reference/index.rst | 1 + docs/source/reference/library.rst | 39 ++++++++++++++-------------- docs/source/reference/oauth.rst | 9 +++++++ docs/source/requirements.txt | 3 ++- pdm.lock | 16 +++++++++++- pyproject.toml | 1 + ytmusicapi/auth/oauth/credentials.py | 3 +++ 14 files changed, 83 insertions(+), 25 deletions(-) create mode 100644 docs/source/_static/css/custom.css delete mode 100644 docs/source/_static/style.css create mode 100644 docs/source/reference/oauth.rst diff --git a/.gitignore b/.gitignore index 3c88026..dbe9b88 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ tests/*.json tests/setup/*.json docs/build +docs/source/reference/api test.cfg **.mp3 .coverage diff --git a/.readthedocs.yml b/.readthedocs.yml index b952cd2..f5414ba 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -4,6 +4,9 @@ build: os: ubuntu-22.04 tools: python: "3.10" + jobs: + pre_build: + - sphinx-apidoc -o docs/source/reference/api ytmusicapi python: install: diff --git a/docs/Makefile b/docs/Makefile index d0c3cbf..4378103 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -17,4 +17,5 @@ help: # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile + sphinx-apidoc -o source/reference/api ../ytmusicapi @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat index 9534b01..f0e8813 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -25,6 +25,7 @@ if errorlevel 9009 ( exit /b 1 ) +sphinx-apidoc -o source/reference/api ../ytmusicapi %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% goto end diff --git a/docs/source/_static/css/custom.css b/docs/source/_static/css/custom.css new file mode 100644 index 0000000..b5a7eba --- /dev/null +++ b/docs/source/_static/css/custom.css @@ -0,0 +1,19 @@ +.wy-nav-content { + max-width: 1080px !important; +} +/* Newlines (\a) and spaces (\20) before each parameter */ +.sig-param::before { + content: "\a\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20"; + white-space: pre; +} + +/* Newline after the last parameter (so the closing bracket is on a new line) */ +dt em.sig-param:last-of-type::after { + content: "\a"; + white-space: pre; +} + +/* To have blue background of width of the block (instead of width of content) */ +dl.class > dt:first-of-type { + display: block !important; +} diff --git a/docs/source/_static/style.css b/docs/source/_static/style.css deleted file mode 100644 index 18dd3fa..0000000 --- a/docs/source/_static/style.css +++ /dev/null @@ -1,3 +0,0 @@ -.wy-nav-content { - max-width: 1080px !important; -} diff --git a/docs/source/conf.py b/docs/source/conf.py index 3ae20fb..6a41575 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -36,7 +36,10 @@ release = __version__ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ["sphinx.ext.autodoc"] +extensions = ["sphinx.ext.autodoc", "sphinx_autodoc_typehints"] + +typehints_use_signature = True +typehints_use_signature_return = True # The suffix of source filenames. source_suffix = ".rst" @@ -51,6 +54,9 @@ templates_path = ["_templates"] # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] +html_css_files = [ + "css/custom.css", +] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/docs/source/reference/index.rst b/docs/source/reference/index.rst index 9192d60..61a4761 100644 --- a/docs/source/reference/index.rst +++ b/docs/source/reference/index.rst @@ -16,3 +16,4 @@ Reference for the YTMusic class. playlists podcasts uploads + api/modules diff --git a/docs/source/reference/library.rst b/docs/source/reference/library.rst index 16a92df..25fe750 100644 --- a/docs/source/reference/library.rst +++ b/docs/source/reference/library.rst @@ -1,22 +1,23 @@ Library ------- -.. currentmodule:: ytmusicapi -.. automethod:: YTMusic.get_library_playlists -.. automethod:: YTMusic.get_library_songs -.. automethod:: YTMusic.get_library_albums -.. automethod:: YTMusic.get_library_artists -.. automethod:: YTMusic.get_library_subscriptions -.. automethod:: YTMusic.get_library_podcasts -.. automethod:: YTMusic.get_library_channels -.. automethod:: YTMusic.get_liked_songs -.. automethod:: YTMusic.get_saved_episodes -.. automethod:: YTMusic.get_history -.. automethod:: YTMusic.add_history_item -.. automethod:: YTMusic.remove_history_items -.. automethod:: YTMusic.rate_song -.. automethod:: YTMusic.edit_song_library_status -.. automethod:: YTMusic.rate_playlist -.. automethod:: YTMusic.subscribe_artists -.. automethod:: YTMusic.unsubscribe_artists -.. automethod:: YTMusic.get_account_info +.. automodule:: ytmusicapi + + .. automethod:: YTMusic.get_library_playlists + .. automethod:: YTMusic.get_library_songs + .. automethod:: YTMusic.get_library_albums + .. automethod:: YTMusic.get_library_artists + .. automethod:: YTMusic.get_library_subscriptions + .. automethod:: YTMusic.get_library_podcasts + .. automethod:: YTMusic.get_library_channels + .. automethod:: YTMusic.get_liked_songs + .. automethod:: YTMusic.get_saved_episodes + .. automethod:: YTMusic.get_history + .. automethod:: YTMusic.add_history_item + .. automethod:: YTMusic.remove_history_items + .. automethod:: YTMusic.rate_song + .. automethod:: YTMusic.edit_song_library_status + .. automethod:: YTMusic.rate_playlist + .. automethod:: YTMusic.subscribe_artists + .. automethod:: YTMusic.unsubscribe_artists + .. automethod:: YTMusic.get_account_info diff --git a/docs/source/reference/oauth.rst b/docs/source/reference/oauth.rst new file mode 100644 index 0000000..74cf8af --- /dev/null +++ b/docs/source/reference/oauth.rst @@ -0,0 +1,9 @@ +OAuth +===== + +.. automodule:: ytmusicapi.auth.oauth + :ignore-module-all: + :members: + :undoc-members: + :show-inheritance: + :imported-members: diff --git a/docs/source/requirements.txt b/docs/source/requirements.txt index 699af98..7b00780 100644 --- a/docs/source/requirements.txt +++ b/docs/source/requirements.txt @@ -1,2 +1,3 @@ sphinx<7 -sphinx-rtd-theme \ No newline at end of file +sphinx-rtd-theme +sphinx-autodoc-typehints>=1.23.0 diff --git a/pdm.lock b/pdm.lock index b42af8e..cf47d07 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:29af69738c3d9d88ee292103b66607d5e026df97aa8d73009be3549df8faeffb" +content_hash = "sha256:c789497f83027a6f145d2ddb8cd18747f395b42f89330109b847bec1a417449c" [[metadata.targets]] requires_python = ">=3.9" @@ -659,6 +659,20 @@ files = [ {file = "sphinx-6.2.1-py3-none-any.whl", hash = "sha256:97787ff1fa3256a3eef9eda523a63dbf299f7b47e053cfcf684a1c2a8380c912"}, ] +[[package]] +name = "sphinx-autodoc-typehints" +version = "1.23.0" +requires_python = ">=3.7" +summary = "Type hints (PEP 484) support for the Sphinx autodoc extension" +groups = ["dev"] +dependencies = [ + "sphinx>=5.3", +] +files = [ + {file = "sphinx_autodoc_typehints-1.23.0-py3-none-any.whl", hash = "sha256:ac099057e66b09e51b698058ba7dd76e57e1fe696cd91b54e121d3dad188f91d"}, + {file = "sphinx_autodoc_typehints-1.23.0.tar.gz", hash = "sha256:5d44e2996633cdada499b6d27a496ddf9dbc95dd1f0f09f7b37940249e61f6e9"}, +] + [[package]] name = "sphinx-rtd-theme" version = "3.0.2" diff --git a/pyproject.toml b/pyproject.toml index 591a271..c164ec0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,4 +82,5 @@ dev = [ "pytest-cov>=4.1.0", "types-requests>=2.31.0.20240218", "pytest-retry>=1.6.3", + "sphinx-autodoc-typehints>=1.23.0", ] diff --git a/ytmusicapi/auth/oauth/credentials.py b/ytmusicapi/auth/oauth/credentials.py index da08caa..3d5c581 100644 --- a/ytmusicapi/auth/oauth/credentials.py +++ b/ytmusicapi/auth/oauth/credentials.py @@ -43,6 +43,9 @@ class OAuthCredentials(Credentials): Class for handling OAuth credential retrieval and refreshing. """ + client_id: str + client_secret: str + def __init__( self, client_id: str,