Repository: takluyver/flit (python)

Issue:
Expose arbitrary project URLs
As discussed on distutils-sig, PyPI allows one to specify arbitrary URLs to show up in the sidebar of pypi.org. It would be great to expose this in flit somehow. Perhaps a `[urls]` or `[metadata.urls]` section where each key is the name of the link and the value is the URL itself, e.g.
```toml
[metadata.urls]
Documentation = "https://flit.readthedocs.io"
Development = "https://github.com/takluyver/flit"
```
Over time this could replace the `homepage` key in `[metadata]` by letting people specify that key themselves.

Pull request:
Project URLs
Add the ability to specify multiple URLs with names, like this:

```toml
[tool.flit.metadata.urls]
Documentation = "https://flit.readthedocs.io/en/latest/"
```

Closes #116.

Patch:
diff --git a/doc/history.rst b/doc/history.rst
index 650ad1e..4effcd6 100644
--- a/doc/history.rst
+++ b/doc/history.rst
@@ -1,6 +1,13 @@
 Release history
 ===============
 
+Version 0.14
+------------
+
+- Multiple links (e.g. documentation, bug tracker) can now be specified in a
+  new :ref:`[tool.flit.metadata.urls] section <pyproject_toml_urls>` of
+  ``pyproject.toml``.
+
 Version 0.13
 ------------
 
diff --git a/doc/pyproject_toml.rst b/doc/pyproject_toml.rst
index 422cda7..09dfcf4 100644
--- a/doc/pyproject_toml.rst
+++ b/doc/pyproject_toml.rst
@@ -115,6 +115,25 @@ Here's the full metadata section from flit itself:
         "Topic :: Software Development :: Libraries :: Python Modules",
     ]
 
+.. _pyproject_toml_urls:
+
+URLs subsection
+~~~~~~~~~~~~~~~
+
+Your project's page on `pypi.org <https://pypi.org/>`_ can show a number of
+links, in addition to the required ``home-page`` URL described above. You can
+point people to documentation or a bug tracker, for example.
+
+This section is called ``[tool.flit.metadata.urls]`` in the file. You can use
+any names inside it. Here it is for flit:
+
+.. code-block:: toml
+
+  [tool.flit.metadata.urls]
+  Documentation = "https://flit.readthedocs.io/en/latest/"
+
+.. versionadded:: 0.14
+
 .. _pyproject_toml_scripts:
 
 Scripts section
diff --git a/flit/common.py b/flit/common.py
index 833f31a..5def1f9 100644
--- a/flit/common.py
+++ b/flit/common.py
@@ -277,6 +277,9 @@ class Metadata:
         for req in self.requires_dist:
             fp.write('Requires-Dist: {}\n'.format(req))
 
+        for url in self.project_urls:
+            fp.write('Project-URL: {}\n'.format(url))
+
         if self.description is not None:
             fp.write('\n' + self.description + '\n')
 
diff --git a/flit/inifile.py b/flit/inifile.py
index 3c1b9e0..234683f 100644
--- a/flit/inifile.py
+++ b/flit/inifile.py
@@ -198,6 +198,11 @@ def _prep_metadata(md_sect, path):
             log.warning(stream.getvalue())
         md_dict['description'] =  raw_desc
 
+    if 'urls' in md_sect:
+        project_urls = md_dict['project_urls'] = []
+        for label, url in md_sect.pop('urls').items():
+            project_urls.append("{}, {}".format(label, url))
+
     for key, value in md_sect.items():
         if key in {'description-file', 'module'}:
             continue
diff --git a/pyproject.toml b/pyproject.toml
index 0299700..276ef75 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -25,5 +25,8 @@ classifiers=["Intended Audience :: Developers",
     "Topic :: Software Development :: Libraries :: Python Modules",
 ]
 
+[tool.flit.metadata.urls]
+Documentation = "https://flit.readthedocs.io/en/latest/"
+
 [tool.flit.scripts]
 flit = "flit:main"


Test patch:
diff --git a/tests/samples/module1-pkg.toml b/tests/samples/module1-pkg.toml
index f7dc8f1..740ec87 100644
--- a/tests/samples/module1-pkg.toml
+++ b/tests/samples/module1-pkg.toml
@@ -7,3 +7,6 @@ author = "Sir Robin"
 author-email = "robin@camelot.uk"
 home-page = "http://github.com/sirrobin/module1"
 description-file = "EG_README.rst"
+
+[tool.flit.metadata.urls]
+Documentation = "https://example.com/module1"