Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Update pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Anselmoo committed Feb 3, 2021
1 parent da5727f commit 2a46d18
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 41 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r dev-requirements.txt
- uses: pre-commit/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
20 changes: 12 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@ repos:
hooks:
- id: trailing-whitespace
- id: check-yaml
- repo: local
- repo: https://github.com/pre-commit/mirrors-pylint
rev: 'v2.6.0' # Use the sha / tag you want to point at
hooks:
- id: pylint
name: pylint
entry: pylint mkdocstrings_sourcelink
language: system
always_run: true
pass_filenames: false
- id: pylint
name: pydocstyle
entry: pydocstyle mkdocstrings_sourcelink
language: system
always_run: true
pass_filenames: false
pass_filenames: true
- repo: https://github.com/pycqa/pydocstyle
rev: 5.1.1 # pick a git hash / tag to point to
hooks:
- id: pydocstyle
name: pydocstyle
entry: pydocstyle mkdocstrings_sourcelink
language: system
always_run: true
pass_filenames: true
48 changes: 21 additions & 27 deletions mkdocstrings_sourcelink/toolbox.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tools for the automatic source link generation for mkdocstrings."""
import importlib
import inspect
from abc import ABC, abstractstaticmethod
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Dict, Optional, Union

Expand All @@ -16,39 +16,38 @@ class BuilderUtilities(ABC):
inheritance.
"""

@abstractstaticmethod
def insert_in_file(markdown_text: str, file_path: Path) -> None:
"""Abstract staticmethod of `insert_in_file`."""
@abstractmethod
def insert_in_file(self) -> None:
"""Abstract method of `insert_in_file`."""

@abstractstaticmethod
def element_to_mkdocstrings(element: str, titles_size: str) -> str:
"""Abstract staticmethod of `element_to_mkdocstrings`."""
@abstractmethod
def element_to_mkdocstrings(self) -> None:
"""Abstract method of `element_to_mkdocstrings`."""

@abstractstaticmethod
def make_source_link(
cls: classmethod,
project_url: Union[str, Dict[str, str]],
source: str = "**source code**",
) -> str:
"""Abstract staticmethod of `make_title`."""
@abstractmethod
def make_source_link(self) -> None:
"""Abstract method of `make_source_link`."""

@abstractstaticmethod
def make_title(cls: classmethod, titles_size: str, underline_title: bool) -> str:
"""Abstract staticmethod of `import_object`."""
@abstractmethod
def make_title(self) -> None:
"""Abstract method of `make_title`."""

@abstractstaticmethod
def return_as_Path(path: str = None) -> Optional[Path]:
"""Abstract staticmethod of `return_as_Path`."""
@abstractmethod
def import_object(self) -> None:
"""Abstract method of `import_object`."""

@abstractmethod
def return_as_Path(self) -> None:
"""Abstract method of `return_as_Path`."""


class Utilities(BuilderUtilities):
"""The `Utilities` build the mkdocstrings and generate the hyperlinks to the source code.
Args:
AbstractUtilities (class): Builder class of the abstract staticmethods of `Utilities`.
AbstractUtilities (class): Builder class of the abstract methods of `Utilities`.
"""

@staticmethod
def insert_in_file(markdown_text: str, file_path: Path) -> None:
"""Insert the markdown formatted text into a new or existing file.
Expand All @@ -74,7 +73,6 @@ def insert_in_file(markdown_text: str, file_path: Path) -> None:
file_path.parent.mkdir(parents=True, exist_ok=True)
file_path.write_text(markdown_text, encoding="utf-8")

@staticmethod
def element_to_mkdocstrings(element: str, titles_size: str) -> str:
"""Converts point separated string into the mkdocstrings format.
Expand All @@ -92,7 +90,6 @@ def element_to_mkdocstrings(element: str, titles_size: str) -> str:
"""
return f"##{titles_size} :::{element}\n"

@staticmethod
def make_source_link(
cls: classmethod,
project_url: Union[str, Dict[str, str]],
Expand Down Expand Up @@ -138,7 +135,6 @@ def make_source_link(
f"</span>"
)

@staticmethod
def make_title(cls: classmethod, titles_size: str, underline_title: bool) -> str:
"""Make the title of the class, function, or method.
Expand All @@ -155,7 +151,6 @@ def make_title(cls: classmethod, titles_size: str, underline_title: bool) -> str
return f"#{titles_size} {cls.fget.__name__}{title_underline}"
return f"#{titles_size} {cls.__name__}{title_underline}"

@staticmethod
def import_object(element: str) -> object:
"""Import an object like class, function, or method from a string.
Expand All @@ -176,7 +171,6 @@ def import_object(element: str) -> object:

return last_object_got

@staticmethod
def return_as_Path(path: str = None) -> Optional[Path]:
"""Converts strings to Path of pathlib.
Expand Down

0 comments on commit 2a46d18

Please sign in to comment.