Skip to content

Commit e695953

Browse files
Rebecca TurnerJon Wayne Parrott
authored andcommitted
Added long_description_content_type (#457)
With [PEP 566](https://www.python.org/dev/peps/pep-0566/#description-content-type-optional), the `long_description` can be Markdown with the `long_description_content_type` arg. This adds documentation for it There were also a couple cases where filenames were enclosed with quotes rather than as code; I've changed those to be `code` as well for consistency. See also: * [Relevant section in PEP 566](https://www.python.org/dev/peps/pep-0566/#description-content-type-optional) * [The CommonMark specification](http://spec.commonmark.org) * [The Description-Content-Type field documentation in the Python packaging documentation](https://packaging.python.org/specifications/core-metadata/#description-content-type-optional)
1 parent 65a0892 commit e695953

1 file changed

Lines changed: 27 additions & 13 deletions

File tree

‎source/tutorials/distributing-packages.rst‎

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ Initial Files
4949
setup.py
5050
~~~~~~~~
5151

52-
The most important file is "setup.py" which exists at the root of your project
52+
The most important file is ``setup.py`` which exists at the root of your project
5353
directory. For an example, see the `setup.py
5454
<https://github.com/pypa/sampleproject/blob/master/setup.py>`_ in the `PyPA
5555
sample project <https://github.com/pypa/sampleproject>`_.
5656

57-
"setup.py" serves two primary functions:
57+
``setup.py`` serves two primary functions:
5858

5959
1. It's the file where various aspects of your project are configured. The
6060
primary feature of ``setup.py`` is that it contains a global ``setup()``
@@ -70,22 +70,25 @@ sample project <https://github.com/pypa/sampleproject>`_.
7070
setup.cfg
7171
~~~~~~~~~
7272

73-
"setup.cfg" is an ini file that contains option defaults for ``setup.py``
73+
``setup.cfg`` is an ini file that contains option defaults for ``setup.py``
7474
commands. For an example, see the `setup.cfg
7575
<https://github.com/pypa/sampleproject/blob/master/setup.cfg>`_ in the `PyPA
7676
sample project <https://github.com/pypa/sampleproject>`_.
7777

7878

79-
README.rst
80-
~~~~~~~~~~
79+
README.rst / README.md
80+
~~~~~~~~~~~~~~~~~~~~~~
8181

82-
All projects should contain a readme file that covers the goal of the
83-
project. The most common format is `reStructuredText
82+
All projects should contain a readme file that covers the goal of the project.
83+
The most common format is `reStructuredText
8484
<http://docutils.sourceforge.net/rst.html>`_ with an "rst" extension, although
85-
this is not a requirement.
85+
this is not a requirement; the `CommonMark <http://spec.commonmark.org/>`_
86+
dialect of `Markdown <https://daringfireball.net/projects/markdown/>`_ is
87+
supported as well (look at ``setup()``'s :ref:`long_description_content_type
88+
<description>` argument).
8689

87-
For an example, see `README.rst
88-
<https://github.com/pypa/sampleproject/blob/master/README.rst>`_ from the `PyPA
90+
For an example, see `README.md
91+
<https://github.com/pypa/sampleproject/blob/master/README.md>`_ from the `PyPA
8992
sample project <https://github.com/pypa/sampleproject>`_.
9093

9194
.. note:: Projects using :ref:`setuptools` have :file:`README.rst` included in
@@ -203,6 +206,7 @@ way is to keep the version in both ``setup.py`` and your code. If you'd rather
203206
not duplicate the value, there are a few ways to manage this. See the
204207
":ref:`Single sourcing the version`" Advanced Topics section.
205208

209+
.. _`description`:
206210

207211
description
208212
~~~~~~~~~~~
@@ -211,6 +215,7 @@ description
211215

212216
description='A sample Python project',
213217
long_description=long_description,
218+
long_description_content_type='text/x-rst',
214219

215220
Give a short and long description for your project.
216221

@@ -225,6 +230,15 @@ the front-page lists of trending projects and new releases, and the list of
225230
projects you maintain within your account profile (such as
226231
https://pypi.org/user/jaraco/).
227232

233+
A `content type
234+
<https://packaging.python.org/specifications/core-metadata/#description-content-type-optional>`_
235+
can be specified with the ``long_description_content_type`` argument, which can
236+
be one of ``text/plain``, ``text/x-rst``, or ``text/markdown``, corresponding
237+
to no formatting, `reStructuredText (reST)
238+
<http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#reference-names>`_,
239+
and the `CommonMark <http://spec.commonmark.org/>`_ dialect of `Markdown
240+
<https://daringfireball.net/projects/markdown/>`_ respectively.
241+
228242
url
229243
~~~
230244

@@ -433,8 +447,8 @@ cases you may need to place data files *outside* of your :term:`packages
433447

434448
Each (directory, files) pair in the sequence specifies the installation
435449
directory and the files to install there. If directory is a relative path, it is
436-
interpreted relative to the installation prefix (Python’s sys.prefix for
437-
pure-Python :term:`distributions <Distribution Package>`, sys.exec_prefix for
450+
interpreted relative to the installation prefix (Python’s ``sys.prefix`` for
451+
pure-Python :term:`distributions <Distribution Package>`, ``sys.exec_prefix`` for
438452
distributions that contain extension modules). Each file name in files is
439453
interpreted relative to the ``setup.py`` script at the top of the project source
440454
distribution.
@@ -754,7 +768,7 @@ To build the wheel:
754768
755769
python setup.py bdist_wheel --universal
756770
757-
You can also permanently set the ``--universal`` flag in "setup.cfg" (e.g., see
771+
You can also permanently set the ``--universal`` flag in ``setup.cfg`` (e.g., see
758772
`sampleproject/setup.cfg
759773
<https://github.com/pypa/sampleproject/blob/master/setup.cfg>`_):
760774

0 commit comments

Comments
 (0)