Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion samples/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# setuptools-markdown_sample
setuptools-markdown\_sample
===========================

This is a **sample** project

Here's some python:

```python
def func(a, b):
c = a + b
return c
```
2 changes: 1 addition & 1 deletion samples/basic/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
setup(
name='setuptools-markdown_sample',
setup_requires=['setuptools-markdown'],
long_description_markdown_filename='README.md',
long_description_filename='README.md',
)
12 changes: 12 additions & 0 deletions samples/rst/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
setuptools-markdown\_sample
===========================

This is a **sample** project

Here's some python:

.. code-block:: python

def func(a, b):
c = a + b
return c
10 changes: 10 additions & 0 deletions samples/rst/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
# setup.py

from setuptools import setup

setup(
name='setuptools-markdown_sample',
setup_requires=['setuptools-markdown'],
long_description_filename='README.rst',
)
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
zip_safe=False,
entry_points="""
[distutils.setup_keywords]
long_description_markdown_filename=setuptools_markdown:long_description_markdown_filename
long_description_filename=setuptools_markdown:long_description_filename
long_description_markdown_filename=setuptools_markdown:long_description_filename
long_description_rst_filename=setuptools_markdown:long_description_filename
"""
)
17 changes: 11 additions & 6 deletions setuptools_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@
logger = logging.getLogger(__name__)


def long_description_markdown_filename(dist, attr, value):
def long_description_filename(dist, attr, value):
logger.debug(
'long_description_markdown_filename: '
'long_description_filename: '
'dist = %r; attr = %r; value = %r',
dist, attr, value)
filename = _get_filepath(value)
output = pypandoc.convert(filename, 'rst')
dist.metadata.long_description = output


def _get_filepath(filename):
frame = _get_code_object()
setup_py_path = inspect.getsourcefile(frame)
markdown_filename = os.path.join(os.path.dirname(setup_py_path), value)
logger.debug('markdown_filename = %r', markdown_filename)
output = pypandoc.convert(markdown_filename, 'rst')
dist.metadata.long_description = output
filepath = os.path.join(os.path.dirname(setup_py_path), filename)
logger.debug('filepath = %r', filepath)
return filepath


def _get_code_object():
Expand Down