Skip to content

Commit

Permalink
build docs with pdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Evidlo committed Dec 3, 2024
1 parent de19108 commit f2cc64c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Pipfile.lock
.idea
.venv*
TMPNOTES
docs/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ tag:

.PHONY: docs
docs:
lazydocs pykeepass --overview-file README.md
pdoc -o docs --docformat google --no-search pykeepass '!pykeepass.icons'
ghp-import -f -p -b docs docs
10 changes: 9 additions & 1 deletion pykeepass/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
"""
.. include:: ../README.md
"""

from .pykeepass import PyKeePass, create_database
from .entry import Entry
from .group import Group
from .attachment import Attachment
from .icons import icons as icons
from .version import __version__

__all__ = ["PyKeePass", "create_database", "__version__"]
__all__ = ["PyKeePass", "Entry", "Group", "Attachment", "icons", "create_database", "__version__"]
21 changes: 11 additions & 10 deletions pykeepass/pykeepass.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

logger = logging.getLogger(__name__)


BLANK_DATABASE_FILENAME = "blank_database.kdbx"
BLANK_DATABASE_LOCATION = os.path.join(os.path.dirname(os.path.realpath(__file__)), BLANK_DATABASE_FILENAME)
BLANK_DATABASE_PASSWORD = "password"
Expand Down Expand Up @@ -323,7 +322,7 @@ def dump_xml(self, filename):
with open(filename, 'wb') as f:
f.write(self.xml())

def _xpath(self, xpath_str, tree=None, first=False, cast=False, **kwargs):
def xpath(self, xpath_str, tree=None, first=False, cast=False, **kwargs):
"""Look up elements in the XML payload and return corresponding object.
Internal function which searches the payload lxml ElementTree for
Expand All @@ -332,18 +331,18 @@ def _xpath(self, xpath_str, tree=None, first=False, cast=False, **kwargs):
is raised.
Args:
xpath_str (str): XPath query for finding element(s)
tree (:obj:`_ElementTree`, :obj:`Element`, optional): use this
xpath_str (`str`): XPath query for finding element(s)
tree (`_ElementTree`, `Element`, optional): use this
element as root node when searching
first (bool): If True, function returns first result or None. If
False, function returns list of matches or empty list. Default
is False.
cast (bool): If True, matches are instead instantiated as
first (`bool`): If True, function returns first result or None. If
False, function returns list of matches or empty list.
(default `False`).
cast (`bool`): If True, matches are instead instantiated as
pykeepass Group, Entry, or Attachment objects. An exception
is raised if a match cannot be cast. Default is False.
is raised if a match cannot be cast. (default `False`)
Returns:
`Group`, `Entry`, `Attachment`, or `lxml.etree.Element`
`list` of `Group`, `Entry`, `Attachment`, or `lxml.etree.Element`
"""

if tree is None:
Expand Down Expand Up @@ -373,6 +372,8 @@ def _xpath(self, xpath_str, tree=None, first=False, cast=False, **kwargs):

return res

_xpath = xpath

def _find(self, prefix, keys_xp, path=None, tree=None, first=False,
history=False, regex=False, flags=None, **kwargs):
"""Internal function for converting a search into an XPath string"""
Expand Down

0 comments on commit f2cc64c

Please sign in to comment.