From 5692b7e9245ee0b568a1c5645c0eea42d438705d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 26 2016 14:01:08 +0000 Subject: [PATCH 1/5] Include the API version in the API documentation --- diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py index 01fd81b..90fd90c 100644 --- a/pagure/api/__init__.py +++ b/pagure/api/__init__.py @@ -449,6 +449,7 @@ def api(): return flask.render_template( 'api.html', + version=__api_version__, api_doc=APIDOC, projects=[ api_git_tags_doc, From 93dd141d19ba84dee970841e212d6e162899aba4 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 26 2016 14:01:51 +0000 Subject: [PATCH 2/5] Give some space to some of the values in the API documentation --- diff --git a/pagure/doc/api.rst b/pagure/doc/api.rst index 39db019..f4fe072 100644 --- a/pagure/doc/api.rst +++ b/pagure/doc/api.rst @@ -23,11 +23,15 @@ Request Encoding ~~~~~~~~~~~~~~~~ The payload of POST and GET requests is encoded as + ``application/x-www-form-urlencoded``. + This is an example URL of a GET request: + ``https://pagure.io/api/0/test/issues?status=Open&tags=Pagure&tags=Enhancement`` + Return Encoding ~~~~~~~~~~~~~~~ From 562e035d0d39b599ebc385abd7febf1bd0373e2f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 26 2016 14:01:59 +0000 Subject: [PATCH 3/5] Add the collapse-down glyph to the title in the API doc This to highlight that the title are clickable and provide more info --- diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 2db2fce..cd3ef51 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -345,6 +345,12 @@ def insert_div(content): for row in content: if row.startswith('
' in row: + row = str(row).replace( + '

', + '

' + '  ' + ) output.append(row) output = "\n".join(output) output = output.replace('

', '\n
', 1) From 85af2ef5d5bb39309c40f09d93947c178ec82136 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 26 2016 14:02:32 +0000 Subject: [PATCH 4/5] Rework the API documentation page to port it to the new UI --- diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index 36eb6c2..73d9e5d 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -384,3 +384,11 @@ color:#aaa; background:#eee; border:1px solid #ccc; } + +.api code { + padding: 0rem 0.4rem; +} + +.api h3 { + padding-left: 1em; +} diff --git a/pagure/templates/api.html b/pagure/templates/api.html index 629e5c2..f7a8206 100644 --- a/pagure/templates/api.html +++ b/pagure/templates/api.html @@ -5,117 +5,134 @@ {% set tag = "index" %} {% block content %} - -

Pagure API Reference

-

This documentation describes the Pagure API v0.

- -{{ api_doc |replace('h1', 'h2') }} - -

List of the API endpoints:

- -

- Projects - - - -

-
-{% for html in projects %} -{{ html | InsertDiv | safe }} -{% endfor %} -
- -{% if issues %} -

- Issues - - - -

-
-{% for html in issues %} -{{ html | InsertDiv | safe }} -{% endfor %} -
-{% endif %} - -

- Pull-requests - - - -

-
-{% for html in requests %} -{{ html | InsertDiv | safe }} -{% endfor %} +
+
+
+

+ +   Pagure API Reference +

+
+ This documentation describes the Pagure API v{{ version[0] }} + revision {{ version[2] }}. +
+
+
+
+
+
+ + {{ api_doc |replace('h1', 'h2') }} + +

List of the API endpoints:

+ +

+ Projects + + + +

+
+ {% for html in projects %} + {{ html | InsertDiv | safe }} + {% endfor %} +
+ + {% if issues %} +

+ Issues + + + +

+
+ {% for html in issues %} + {{ html | InsertDiv | safe }} + {% endfor %} +
+ {% endif %} + +

+ Pull-requests + + + +

+
+ {% for html in requests %} + {{ html | InsertDiv | safe }} + {% endfor %} +
+ +

+ Users + + + +

+
+ {% for html in users %} + {{ html | InsertDiv | safe }} + {% endfor %} +
+ +

+ Extras + + + +

+ +
+ {% for html in extras %} + {{ html | InsertDiv |safe }} + {% endfor %} +
+ +
+
+
- -

- Users - - - -

-
-{% for html in users %} -{{ html | InsertDiv | safe }} -{% endfor %} -
- -

- Extras - - - -

- -
-{% for html in extras %} -{{ html | InsertDiv |safe }} -{% endfor %} -
- {% endblock %} {% block jscripts %} {{ super() }} {% endblock %} From d3ab0ca228fc19a4ccf94efa32908fcb64bf17db Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 26 2016 15:29:13 +0000 Subject: [PATCH 5/5] Split the API version by '.' so that we can reach 0.10 or 10.5 --- diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py index 90fd90c..d3294e7 100644 --- a/pagure/api/__init__.py +++ b/pagure/api/__init__.py @@ -449,7 +449,7 @@ def api(): return flask.render_template( 'api.html', - version=__api_version__, + version=__api_version__.split('.'), api_doc=APIDOC, projects=[ api_git_tags_doc, diff --git a/pagure/templates/api.html b/pagure/templates/api.html index f7a8206..b035f06 100644 --- a/pagure/templates/api.html +++ b/pagure/templates/api.html @@ -14,7 +14,7 @@
This documentation describes the Pagure API v{{ version[0] }} - revision {{ version[2] }}. + revision {{ version[1] }}.