Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts authored Feb 21, 2021
2 parents 3eda38a + 6dbc3ad commit 4496d0c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Contributing Guidelines

:+1::tada: First off, thanks for considering to contribute to this project! :tada::+1:

These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

## Git hooks

We use git hooks through [pre-commit](https://pre-commit.com/) to enforce and automatically check some "rules". Please install it before to push any commit.

See the relevant configuration file: `.pre-commit-config.yaml`.

## Code Style

Make sure your code *roughly* follows [PEP-8](https://www.python.org/dev/peps/pep-0008/) and keeps things consistent with the rest of the code:

- docstrings: [sphinx-style](https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html#the-sphinx-docstring-format) is used to write technical documentation.
- formatting: [black](https://black.readthedocs.io/) is used to automatically format the code without debate.
- static analisis: [flake8](https://flake8.pycqa.org/en/latest/) is used to catch some dizziness and keep the source code healthy.
26 changes: 22 additions & 4 deletions mkdocs_rss_plugin/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from urllib.parse import urlencode, urlparse, urlunparse

# 3rd party
import markdown
from git import GitCommandError, GitCommandNotFound, InvalidGitRepositoryError, Repo
from mkdocs.config.config_options import Config
from mkdocs.structure.pages import Page
Expand Down Expand Up @@ -262,18 +263,35 @@ def get_description_or_abstract(self, in_page: Page, chars_count: int = 150) ->
"""Returns description from page meta. If it doesn't exist, use the \
{chars_count} first characters from page content (in markdown).
:param Page in_page: [description]
:param int chars_count: [description]. Defaults to: 150 - optional
:param Page in_page: page to look at
:param int chars_count: if page.meta.description is not set, number of chars \
of the content to use. Defaults to: 150 - optional
:return: page description to use
:rtype: str
"""
if in_page.meta.get("description"):
return in_page.meta.get("description")
elif in_page.content:
return in_page.content[:chars_count]
if len(in_page.content) < chars_count:
return markdown.markdown(
in_page.content[:chars_count], output_format="html5"
)
else:
return markdown.markdown(
"{}...".format(in_page.content[: chars_count - 3]),
output_format="html5",
)
elif in_page.markdown:
return in_page.markdown[:chars_count]
if len(in_page.markdown) < chars_count:
return markdown.markdown(
in_page.markdown[:chars_count], output_format="html5"
)
else:
return markdown.markdown(
"{}...".format(in_page.markdown[: chars_count - 3]),
output_format="html5",
)
else:
return ""

Expand Down
2 changes: 1 addition & 1 deletion requirements/documentation-rtd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Documentation (for devs)
# -----------------------
sphinx>=3.2,<3.5
sphinx>=3.2,<3.6
sphinx-autodoc-typehints>=1.10,<1.12
sphinx-copybutton>=0.3,<0.4
sphinx-markdown-tables>=0.0.15,<0.0.16
Expand Down

0 comments on commit 4496d0c

Please sign in to comment.