From 09a0297320055e02a9928344dd12482940fa3e89 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Mon, 10 Apr 2023 10:53:16 -0400 Subject: [PATCH] 18799: Remove old API documentation scripts These are no longer used. Arvados-DCO-1.1-Signed-off-by: Brett Smith --- doc/gen_api_method_docs.py | 130 ------------------------------------- doc/gen_api_schema_docs.py | 79 ---------------------- 2 files changed, 209 deletions(-) delete mode 100755 doc/gen_api_method_docs.py delete mode 100755 doc/gen_api_schema_docs.py diff --git a/doc/gen_api_method_docs.py b/doc/gen_api_method_docs.py deleted file mode 100755 index 9a29d46167..0000000000 --- a/doc/gen_api_method_docs.py +++ /dev/null @@ -1,130 +0,0 @@ -#! /usr/bin/env python -# Copyright (C) The Arvados Authors. All rights reserved. -# -# SPDX-License-Identifier: CC-BY-SA-3.0 - -# gen_api_method_docs.py -# -# Generate docs for Arvados methods. -# -# This script will retrieve the discovery document at -# https://localhost:9900/discovery/v1/apis/arvados/v1/rest -# and will generate Textile documentation files in the current -# directory. - -import argparse -import pprint -import re -import requests -import os -import sys #debugging - -p = argparse.ArgumentParser(description='Generate Arvados API method documentation.') - -p.add_argument('--host', - type=str, - default='localhost', - help="The hostname or IP address of the API server") - -p.add_argument('--port', - type=int, - default=9900, - help="The port of the API server") - -p.add_argument('--output-dir', - type=str, - default='.', - help="Directory in which to write output files.") - -args = p.parse_args() - -api_url = 'https://{host}:{port}/discovery/v1/apis/arvados/v1/rest'.format(**vars(args)) - -r = requests.get(api_url, verify=False) -if r.status_code != 200: - raise Exception('Bad status code %d: %s' % (r.status_code, r.text)) - -if 'application/json' not in r.headers.get('content-type', ''): - raise Exception('Unexpected content type: %s: %s' % - (r.headers.get('content-type', ''), r.text)) - -api = r.json() - -resource_num = 0 -for resource in sorted(api[u'resources']): - resource_num = resource_num + 1 - out_fname = os.path.join(args.output_dir, resource + '.textile') - if os.path.exists(out_fname): - backup_name = out_fname + '.old' - try: - os.rename(out_fname, backup_name) - except OSError as e: - print "WARNING: could not back up {0} as {1}: {2}".format( - out_fname, backup_name, e) - outf = open(out_fname, 'w') - outf.write( -"""--- -navsection: api -navmenu: API Methods -title: "{resource}" -navorder: {resource_num} ---- - -h1. {resource} - -Required arguments are displayed in %{{background:#ccffcc}}green%. - -""".format(resource_num=resource_num, resource=resource)) - - methods = api['resources'][resource]['methods'] - for method in sorted(methods.keys()): - methodinfo = methods[method] - outf.write( -""" -h2. {method} - -{description} - -Arguments: - -table(table table-bordered table-condensed). -|_. Argument |_. Type |_. Description |_. Location |_. Example | -""".format( - method=method, description=methodinfo['description'])) - - required = [] - notrequired = [] - for param, paraminfo in methodinfo['parameters'].iteritems(): - paraminfo.setdefault(u'description', '') - paraminfo.setdefault(u'location', '') - limit = '' - if paraminfo.get('minimum', '') or paraminfo.get('maximum', ''): - limit = "range {0}-{1}".format( - paraminfo.get('minimum', ''), - paraminfo.get('maximum', 'unlimited')) - if paraminfo.get('default', ''): - if limit: - limit = limit + '; ' - limit = limit + 'default %d' % paraminfo['default'] - if limit: - paraminfo['type'] = '{0} ({1})'.format( - paraminfo['type'], limit) - - row = "|{param}|{type}|{description}|{location}||\n".format( - param=param, **paraminfo) - if paraminfo.get('required', False): - required.append(row) - else: - notrequired.append(row) - - for row in sorted(required): - outf.write("{background:#ccffcc}." + row) - for row in sorted(notrequired): - outf.write(row) - - # pprint.pprint(methodinfo) - - outf.close() - print "wrote ", out_fname - - diff --git a/doc/gen_api_schema_docs.py b/doc/gen_api_schema_docs.py deleted file mode 100755 index 3c3ab2eadb..0000000000 --- a/doc/gen_api_schema_docs.py +++ /dev/null @@ -1,79 +0,0 @@ -#! /usr/bin/env python -# Copyright (C) The Arvados Authors. All rights reserved. -# -# SPDX-License-Identifier: CC-BY-SA-3.0 - -# gen_api_schema_docs.py -# -# Generate Textile documentation pages for Arvados schema resources. - -import requests -import re -import os - -r = requests.get('https://localhost:9900/arvados/v1/schema', - verify=False) -if r.status_code != 200: - raise Exception('Bad status code %d: %s' % (r.status_code, r.text)) - -if 'application/json' not in r.headers.get('content-type', ''): - raise Exception('Unexpected content type: %s: %s' % - (r.headers.get('content-type', ''), r.text)) - -schema = r.json() -navorder = 0 -for resource in sorted(schema.keys()): - navorder = navorder + 1 - properties = schema[resource] - res_api_endpoint = re.sub(r'([a-z])([A-Z])', r'\1_\2', resource).lower() - outfile = "{}.textile".format(resource) - if os.path.exists(outfile): - outfile = "{}_new.textile".format(resource) - print outfile, "..." - with open(outfile, "w") as f: - f.write("""--- -layout: default -navsection: api -navmenu: Schema -title: {resource} ---- - -h1. {resource} - -A **{resource}** represents... - -h2. Methods - - See "REST methods for working with Arvados resources":{{{{site.baseurl}}}}/api/methods.html - -API endpoint base: @https://{{{{ site.arvados_api_host }}}}/arvados/v1/{res_api_endpoint}@ - -h2. Creation - -h3. Prerequisites - -Prerequisites for creating a {resource}. - -h3. Side effects - -Side effects of creating a {resource}. - -h2. Resources - -Each {resource} has, in addition to the usual "attributes of Arvados resources":resources.html: - -table(table table-bordered table-condensed). -|_. Attribute|_. Type|_. Description|_. Example| -""".format( - resource=resource, - navorder=navorder, - res_api_endpoint=res_api_endpoint)) - - for prop in properties: - if prop not in ['id', 'uuid', 'href', 'kind', 'etag', 'self_link', - 'owner_uuid', 'created_at', - 'modified_by_client_uuid', - 'modified_by_user_uuid', - 'modified_at']: - f.write('|{name}|{type}|||\n'.format(**prop)) - -- 2.30.2