Skip to content

Commit

Permalink
✨ markdown and plaintext readmes.
Browse files Browse the repository at this point in the history
Signed-off-by: rjdbcm <[email protected]>
  • Loading branch information
rjdbcm committed May 14, 2024
1 parent a0139bb commit bf5f5ac
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ foreach name : namespace
message('installing', command)
endif
if suite.enabled() and command in module_only
modules += [command]
modules += [command.underscorify()] # we should collapse repeated `_`
endif
flag = disabler()
if (
Expand Down
7 changes: 4 additions & 3 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ option(
'flake8-leading-blank-lines',
'flake8-tidy-imports',
'flake8-pyi',
'restructuredtext-lint',
'readme-renderer',
],
)
option(
Expand Down Expand Up @@ -200,6 +200,7 @@ option(
'isort',
'pyright',
'mypy',
'readme-renderer',
],
)
# test application arguments
Expand Down Expand Up @@ -277,9 +278,9 @@ option(
)
option('args-coverage', type: 'array', value: ['debug', 'config'], yield: true)
option(
'args-restructuredtext-lint',
'args-readme-renderer',
type: 'array',
value: ['--level=warning', 'README.rst'],
value: ['README.rst'],
yield: true,
)
option(
Expand Down
4 changes: 2 additions & 2 deletions ozi/fix/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def render_pkg_info(target: Path, name: str, _license: str) -> Message:
setuptools_scm.get('version_file_template', '@README_TEXT@')
.replace(
'@README_TEXT@',
target.joinpath('README.rst').read_text(),
target.joinpath('README').read_text(),
)
.replace('@PROJECT_NAME@', name)
.replace('@LICENSE@', _license)
Expand Down Expand Up @@ -126,7 +126,7 @@ def required_files(
expected_files = ()
for file in expected_files:
f = rel_path / file
if not target.joinpath(f).exists():
if not target.joinpath(f).exists(): # pragma: no cover
TAP.not_ok('MISSING', str(f))
continue # pragma: defer to https://github.com/nedbat/coveragepy/issues/198
TAP.ok(str(f))
Expand Down
2 changes: 1 addition & 1 deletion ozi/lint/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source_child_lint_children = [
'isort',
'mypy',
'pyright',
'restructuredtext-lint',
'readme-renderer',
]
if (get_option('dev').enabled() or get_option('lint').enabled())
foreach package : source_child_lint_children
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions ozi/lint/readme-renderer/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
readme-renderer
1 change: 0 additions & 1 deletion ozi/lint/restructuredtext-lint/requirements.in

This file was deleted.

7 changes: 7 additions & 0 deletions ozi/new/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@
help='Classifier: Development Status (Single Use)(default: "1 - Planning")',
type=str,
)
defaults.add_argument(
'--long-description-content-type',
'--readme-type',
default='rst',
choices=('rst', 'md', 'txt'),
help='Description-Content-Type',
)
optional.add_argument(
'-r',
'--dist-requires',
Expand Down
22 changes: 22 additions & 0 deletions ozi/pkg_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
dcolon = sspace + Suppress(Literal('::')) + sspace
classifier = Suppress(White(' ', min=2)) + Suppress(Literal('Classifier:')) + sspace
pep639_headers = Forward()
pep639_headers_md = Forward()
license_expression = classifier + (
Keyword('License-Expression')
+ dcolon
Expand All @@ -32,11 +33,32 @@
Keyword('License-File') + dcolon + oneOf(['LICENSE', 'LICENSE.txt'])
).set_parse_action(lambda t: {str(t[0]): str(t[1])})
pep639_headers <<= license_expression + license_file
pep639_headers_md <<= (
Suppress(
Keyword('[comment]') + Literal('#') + Literal('('),
)
+ license_expression
+ Suppress(Literal(')'))
+ Suppress(
Keyword('[comment]') + Literal('#') + Literal('('),
)
+ license_file
+ Suppress(Literal(')'))
)
extra_classifiers_comment = (
Suppress(
Keyword('..') + CaselessKeyword('ozi'),
)
+ pep639_headers
| Suppress(
Keyword('[comment]')
+ Keyword('#')
+ Literal('(')
+ Keyword('..')
+ CaselessKeyword('ozi')
+ Literal(')'),
)
+ pep639_headers_md
)


Expand Down
2 changes: 1 addition & 1 deletion ozi/spec/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ClassicLint(CheckpointSuite):
'isort': 'isort',
'mypy': 'mypy',
'pyright': 'pyright',
'restructuredtext-lint': 'restructuredtext-lint',
'readme-renderer': 'readme-renderer',
},
)
plugin: Mapping[str, str] = field(
Expand Down
2 changes: 1 addition & 1 deletion ozi/spec/pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PkgRequired(Default):
"""Required files for OZI project publishing."""

root: tuple[str, ...] = (
'README.rst',
'README',
'CHANGELOG.md',
'pyproject.toml',
'LICENSE.txt',
Expand Down
4 changes: 2 additions & 2 deletions ozi/spec/src.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SrcRequired(Default):
"""Required files for OZI to output with ``ozi-new``."""

root: tuple[str, ...] = (
'README.rst',
'README',
'.gitignore',
'pyproject.toml',
'meson.build',
Expand Down Expand Up @@ -77,7 +77,7 @@ class SrcTemplate(Default):
'meson.build',
'meson.options',
'pyproject.toml',
'README.rst',
'README',
'LICENSE.txt',
'requirements.in',
'CHANGELOG.md',
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blastpipe~=2024.6.3
blastpipe~=2024.7.4
GitPython>=3
dnspython
idna>=2
Expand Down
3 changes: 3 additions & 0 deletions tests/test_ozi_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
if k not in ['Private']
],
),
'long_description_content_type': st.sampled_from(['rst', 'md', 'txt']),
},
),
license_expression=st.data(),
Expand Down Expand Up @@ -219,6 +220,7 @@ def test_new_project_bad_args( # noqa: DC102, RUF100
'status': ['1 - Planning'],
'dist_requires': [],
'allow_file': [],
'long_description_content_type': 'rst',
}
project_dict.update(item)
namespace = argparse.Namespace(**project_dict)
Expand Down Expand Up @@ -258,6 +260,7 @@ def test_new_project_bad_target_not_empty( # noqa: DC102, RUF100
'status': ['1 - Planning'],
'dist_requires': [],
'allow_file': [],
'long_description_content_type': 'rst',
}
(project_dict['target'] / 'foobar').touch() # type: ignore
namespace = argparse.Namespace(**project_dict)
Expand Down

0 comments on commit bf5f5ac

Please sign in to comment.