Skip to content

Commit

Permalink
Improve pyproject.toml, add py.typed
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoPrevato authored Apr 26, 2023
1 parent 8c75306 commit e031b25
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.2] - 2023-04-25
- Fixes detail in the `contribs` plugin: when the name is specified for a
contributor by email address, it is used.
- Improves `pyproject.toml`.
- Adds `py.typed` files.

## [1.0.1] - 2023-04-25
- Improves the `contribs` plugin, adding the possibility to document
contributors for a page also using `.txt` files close to `.md` files. This
Expand Down
2 changes: 1 addition & 1 deletion neoteroi/mkdocs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.1"
__version__ = "1.0.2"
Empty file added neoteroi/mkdocs/cards/py.typed
Empty file.
3 changes: 3 additions & 0 deletions neoteroi/mkdocs/contribs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def _get_contributors(self, page_file: File) -> List[Contributor]:
if parent:
parent.count += contributor.count
continue
else:
# use configured name
contributor.name = contributor_info["name"]

# should contributor information be merged with another object?
if self._merge_contributor_by_email(
Expand Down
Empty file.
Empty file.
Empty file added neoteroi/mkdocs/oad/py.typed
Empty file.
Empty file.
Empty file.
Empty file.
20 changes: 7 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,14 @@ dependencies = [
[tool.hatch.version]
path = "neoteroi/mkdocs/__init__.py"

[tool.hatch.build.targets.wheel]
packages = ["neoteroi"]

[tool.hatch.build.targets.sdist]
exclude = [
"/.github",
"/docs",
"/deps",
"/styles",
"/tests",
"mkdocs-plugins.code-workspace",
"Makefile",
"CODE_OF_CONDUCT.md",
".isort.cfg",
".gitignore",
".flake8"
]
exclude = ["tests"]

[tool.hatch.build]
only-packages = true

[project.urls]
"Homepage" = "https://github.com/Neoteroi/mkdocs-plugins"
Expand Down
34 changes: 34 additions & 0 deletions tests/test_contribs.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,40 @@ def test_contributor_alt_names():
]


def test_contributor_name_set():
"""
When a name is specified for a contributor by email, it is used.
"""
plugin = ContribsPlugin()

contributors = [
Contributor("Charlie Marrone", "[email protected]", count=2),
]

reader_mock = Mock(ContributionsReader)
reader_mock.get_contributors.return_value = contributors

file_mock = Mock(File)
file_mock.src_path = Path("foo.txt")
plugin._contribs_reader = reader_mock
result = plugin._get_contributors(file_mock)

assert result == contributors

# setting
plugin.config = {
"contributors": [
{"email": "[email protected]", "name": "Charlie Brown"}
]
}

result = plugin._get_contributors(file_mock)

assert result == [
Contributor("Charlie Brown", "[email protected]", count=2),
]


def test_contributors_exclude():
handler = ContribsPlugin()
handler.config = _get_contribs_config()
Expand Down

0 comments on commit e031b25

Please sign in to comment.