#1821 browsable api
Merged 4 years ago by tkopecek. Opened 4 years ago by tkopecek.
tkopecek/koji issue1813  into  master

file modified
+1 -4
@@ -2445,10 +2445,7 @@ 

          parser.error(_("This command takes no arguments"))

          assert False  # pragma: no cover

      activate_session(session, goptions)

-     tmplist = [(x['name'], x) for x in session._listapi()]

-     tmplist.sort()

-     funcs = [x[1] for x in tmplist]

-     for x in funcs:

+     for x in sorted(session._listapi(), key=lambda x: x['name']):

          if 'argdesc' in x:

              args = x['argdesc']

          elif x['args']:

@@ -0,0 +1,15 @@ 

+ #include "includes/header.chtml"

+ 

+ <h4>API reference</h4>

+ 

+ <ul>

+ #for method in $methods

+   <li>

+      <pre><b>$method['name']$method['argdesc']</b>

+   $method['doc']

+      </pre>

+   </li>

+ #end for

+ </ul>

+ 

+ #include "includes/footer.chtml"

@@ -74,6 +74,7 @@ 

              <li id="hostsTab"><a href="hosts">Hosts</a></li>

              <li id="reportsTab"><a href="reports">Reports</a></li>

              <li id="searchTab"><a href="search">Search</a></li>

+             <li id="apiTab"><a href="api">API</a></li>

            </ul>

          </div><!-- end mainNav -->

  

file modified
+10
@@ -2344,6 +2344,16 @@ 

      else:

          return _genHTML(environ, 'search.chtml')

  

+ 

+ def api(environ):

+     values = _initValues(environ, 'API', 'api')

+     server = _getServer(environ)

+ 

+     values['methods'] = sorted(server._listapi(), key=lambda x: x['name'])

+ 

+     return _genHTML(environ, 'api.chtml')

+ 

+ 

  def watchlogs(environ, taskID):

      values = _initValues(environ)

      if isinstance(taskID, list):

file modified
+2 -1
@@ -146,7 +146,8 @@ 

  body#hosts #mainNav li#hostsTab a,

  body#buildtargets #mainNav li#buildtargetsTab a,

  body#reports #mainNav li#reportsTab a,

- body#search #mainNav li#searchTab a {

+ body#search #mainNav li#searchTab a,

+ body#api #mainNav li#apiTab a {

      background-color: #eee;

      color: #000;

  }

I think we should wrap this in

$help

This is great!

I think we should wrap this in <pre>...</pre>

rebased onto 3641e376b3b480d1bd9b9e811b7c0ed3e9137e0e

4 years ago

It would be really handy to expand everything on one single web page, like we currently do with the output of koji list-api. This would let users use "ctrl-f" in their browser to quickly find all the API calls that have to do with content generators, or external repos, for example. And with mobile interfaces, scrolling is much less painful than clicking on many links and then going "back" in the browser.

What do you think?

rebased onto 79c3f4e

4 years ago

Yep, it seems reasonable. I've updated PR to have only one page.

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

4 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

4 years ago

Commit ef91057 fixes this pull-request

Pull-Request has been merged by tkopecek

4 years ago