Skip to content

Commit

Permalink
Readthedocs fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfjlaros committed Oct 19, 2024
1 parent 5c0a4d3 commit a884cff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
1 change: 1 addition & 0 deletions docs/.readthedocs.yaml → .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ sphinx:

python:
install:
- path: .
- requirements: docs/requirements.txt
15 changes: 9 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from simple_rpc import _get_metadata
from importlib.metadata import metadata


author = _get_metadata('Author')
copyright = _get_metadata('Author')
project = _get_metadata('Name')
release = _get_metadata('Version')
_package_metadata = metadata('arduino_simple_rpc')

author = _package_metadata('Author')
copyright = _package_metadata('Author')
project = _package_metadata('Name')
release = _package_metadata('Version')

autoclass_content = 'both'
extensions = ['sphinx.ext.autodoc', 'sphinx_autodoc_typehints', 'sphinxarg.ext']
extensions = [
'sphinx.ext.autodoc', 'sphinx_autodoc_typehints', 'sphinxarg.ext']
master_doc = 'index'
25 changes: 6 additions & 19 deletions simple_rpc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
from pkg_resources import DistributionNotFound, get_distribution
from importlib.metadata import metadata

from .extras import dict_to_object, object_to_dict
from .simple_rpc import Interface, SerialInterface, SocketInterface


def _get_metadata(name: str) -> str:
try:
pkg = get_distribution('arduino_simple_rpc')
except DistributionNotFound:
pkg = get_distribution('simple_rpc')

for line in pkg.get_metadata_lines(pkg.PKG_INFO):
if line.startswith('{}: '.format(name)):
return line.split(': ')[1]

return ''


_package_metadata = metadata('arduino_simple_rpc')
_copyright_notice = 'Copyright (c) {} <{}>'.format(
_get_metadata('Author'), _get_metadata('Author-email'))

usage = [_get_metadata('Summary'), _copyright_notice]
_package_metadata['Author'], _package_metadata['Author-email'])
usage = [_package_metadata['Summary'], _copyright_notice]


def doc_split(func: callable) -> str:
Expand All @@ -29,5 +16,5 @@ def doc_split(func: callable) -> str:

def version(name: str) -> str:
return '{} version {}\n\n{}\nHomepage: {}'.format(
_get_metadata('Name'), _get_metadata('Version'), _copyright_notice,
_get_metadata('Home-page'))
_package_metadata['Name'], _package_metadata['Version'],
_copyright_notice, _package_metadata['Home-page'])

0 comments on commit a884cff

Please sign in to comment.