Generates and returns documentation for this API endpoint
963947
def documentation(self, base_url=None, api_version=None, prefix=""):
        """"""
        documentation = OrderedDict()
        base_url = self.base_url if base_url is None else base_url
        overview = self.api.doc
        if overview:
            documentation['overview'] = overview

        version_dict = OrderedDict()
        versions = self.versions
        versions_list = list(versions)
        if None in versions_list:
            versions_list.remove(None)
        if False in versions_list:
            versions_list.remove(False)
        if api_version is None and len(versions_list) > 0:
            api_version = max(versions_list)
            documentation['version'] = api_version
        elif api_version is not None:
            documentation['version'] = api_version
        if versions_list:
            documentation['versions'] = versions_list
        for router_base_url, routes in self.routes.items():
            for url, methods in routes.items():
                for method, method_versions in methods.items():
                    for version, handler in method_versions.items():
                        if getattr(handler, 'private', False):
                            continue
                        if version is None:
                            applies_to = versions
                        else:
                            applies_to = (version, )
                        for version in applies_to:
                            if api_version and version != api_version:
                                continue
                            if base_url and router_base_url != base_url:
                                continue
                            doc = version_dict.setdefault(url, OrderedDict())
                            doc[method] = handler.documentation(doc.get(method, None), version=version, prefix=prefix,
                                                                base_url=router_base_url, url=url)
        documentation['handlers'] = version_dict
        return documentation
875396
def write_documentation(self, doc_type):
        
        for handler_name in sorted(self._documentation):
            if "controller." in handler_name:
                server_type = "controller"
            elif "compute" in handler_name:
                server_type = "compute"
            else:
                server_type = "root"

            if doc_type != server_type:
                continue

            print("Build {}".format(handler_name))

            for path in sorted(self._documentation[handler_name]):

                api_version = self._documentation[handler_name][path]["api_version"]
                if api_version is None:
                    continue

                filename = self._file_path(path)
                handler_doc = self._documentation[handler_name][path]
                handler = handler_name.replace(server_type + ".", "")

                self._create_handler_directory(handler, api_version, server_type)
                with open("{}/api/v{}/{}/{}/{}.rst".format(self._directory, api_version, server_type, handler, filename), 'w+') as f:
                    f.write('{}\n------------------------------------------------------------------------------------------------------------------------------------------\n\n'.format(path))
                    f.write('.. contents::\n')
                    for method in handler_doc["methods"]:
                        f.write('\n{} {}\n'.format(method["method"], path.replace("{", '**{').replace("}", "}**")))
                        f.write('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n')
                        f.write('{}\n\n'.format(method["description"]))

                        if len(method["parameters"]) > 0:
                            f.write("Parameters\n**********\n")
                            for parameter in method["parameters"]:
                                desc = method["parameters"][parameter]
                                f.write("- **{}**: {}\n".format(parameter, desc))
                            f.write("\n")

                        f.write("Response status codes\n**********************\n")
                        for code in method["status_codes"]:
                            desc = method["status_codes"][code]
                            f.write("- **{}**: {}\n".format(code, desc))
                        f.write("\n")

                        if "properties" in method["input_schema"]:
                            f.write("Input\n*******\n")
                            self._write_definitions(f, method["input_schema"])
                            self._write_json_schema(f, method["input_schema"])

                        if "properties" in method["output_schema"]:
                            f.write("Output\n*******\n")
                            self._write_json_schema(f, method["output_schema"])

                        self._include_query_example(f, method, path, api_version, server_type)
547574
public function actionDocumentation()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;

        if ($this->apiDocsCacheEnabled) {
            $filename = str_replace('\\', '-', static::class);
            $path = Yii::getAlias($this->apiDocsCacheDirectory) . $filename . '.json';

            if (file_exists($path)) {
                $doc = file_get_contents($path);
            } else {
                $doc = $this->generator->getJson($this->version);
                // Store the credentials to disk.
                if (!is_dir(dirname($path))) {
                    mkdir(dirname($path), 0700, true);
                }
                file_put_contents($path, Json::encode($doc));
            }
        } else {
            $doc = $this->generator->getJson($this->version);
        }
        return $doc;
    }
1086995
def _get_xml_doc(self, endpoint, query, is_post=False):
        
        response = self._get_response(endpoint, query, is_post=is_post)
        return minidom.parse(response.text)
55917
def build_documentation_lines(self):
        
        return [
            line_string for key in sorted(self.keys)
            for line_string in self.build_paramter_string(key)
        ]
102532
def fetch(cls, id, api_key=None, endpoint=None, add_headers=None,
              **kwargs):
        
        if endpoint is None:
            endpoint = cls.get_endpoint()

        inst = cls(api_key=api_key)
        parse_key = cls.sanitize_ep(endpoint).split("/")[-1]
        endpoint = '/'.join((endpoint, id))
        data = cls._parse(inst.request('GET',
                                       endpoint=endpoint,
                                       add_headers=add_headers,
                                       query_params=kwargs),
                          key=parse_key)
        inst._set(data)
        return inst
1311196
def gendocs():
    ""
    helppage = path("docs/references-cli-usage.rst")
    content = [
        ".. automatically generated using 'paver gendocs'.",
        "",
        ".. contents::",
        "    :local:",
        "",
        ".. note::",
        "",
        "    The help output presented here applies to version ``%s`` of the tools."
            % sh("pyroadmin --version", capture=True).split()[1],
        "",
    ]

    for tool in sorted(project.entry_points["console_scripts"]):
        tool, _ = tool.split(None, 1)
        content.extend([
            ".. _cli-usage-%s:" % tool,
            "",
            tool,
            '^' * len(tool),
            "",
            "::",
            "",
        ])
        help_opt = "--help-fields --config-dir /tmp" if tool == "rtcontrol" else "--help"
        help_txt = sh("%s -q %s" % (tool, help_opt), capture=True, ignore_error=True).splitlines()
        content.extend('    ' + i for i in help_txt
                       if ' on Python ' not in i and 'Copyright (c) 200' not in i
                       and 'see the full documentation' not in i
                       and '    https://pyrocore.readthedocs.io/' not in i)
        content.extend([
            "",
        ])

    content = [line.rstrip() for line in content if all(
        i not in line for i in (", Copyright (c) ", "Total time: ", "Configuration file '/tmp/")
    )]
    content = [line for line, succ in zip(content, content[1:] + ['']) if line or succ] # filter twin empty lines
    helppage.write_lines(content)
401327
def get_callable_documentation(the_callable):
    
    return wrap_text_in_a_box(
        title=get_callable_signature_as_string(the_callable),
        body=(getattr(the_callable, '__doc__') or 'No documentation').replace(
            '\n', '\n\n'),
        style='ascii_double')
270585
public static synchronized void generate() {
        LOGGER.debug("Generating documentation of test documentation included in pythonlib directories.");
        try {
            IS_RUNNING = true;
            List<File> pythonLibDirectories = findPythonLibDirectories(ROOT_SCRIPT_DIRECTORY);

            List<File> pythonScriptFiles = findPythonScripts(pythonLibDirectories);
            for (File script : pythonScriptFiles) {
                if (hasToGenerateDocumentation(script)) {
                    GenerateTestStepsModulesDoc.generate(script.getAbsolutePath());
                }
            }
            ALREADY_RUN = true;
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            IS_RUNNING = false;
        }
    }
361895
def generate_html
      FileUtils.rm_rf(Rails.root.join('tmp/apidocs'))
      options = [Rails.root.join("app/controllers").to_s, "--op=#{Rails.root.join('tmp/apidocs')}"]

      self.store = RDoc::Store.new

      @options = load_options
      @options.parse options
      @exclude = @options.exclude

      @last_modified = setup_output_dir @options.op_dir, @options.force_update

      @store.encoding = @options.encoding if @options.respond_to? :encoding
      @store.dry_run = @options.dry_run
      @store.main = @options.main_page
      @store.title = @options.title
      @store.path = @options.op_dir

      @start_time = Time.now
      @store.load_cache
      @options.default_title = "RDoc Documentation"

      parse_files @options.files
      @store.complete @options.visibility

      formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new)

      routes = routes_by_regex.map do |r|
        {verb: r[:verb],
         path: r[:path].sub('(.:format)', ''),
         class_name: gen_class_name(r),
         action_name: gen_action_name(r)
        }
      end.each do |r|
        doc = document_route(r)
        r[:html_comment] = doc ? doc.accept(formatter) : ""
      end.select { |r| r[:class_name] != "ApidocsController" }

      puts routes.inspect
      routes
    end
434460
def to_json(self):
        
        endpoints = []
        for endpoint in self.endpoints:
            list_fields = endpoint.fields
            resource_type = endpoint.Meta.resource_type
            table = endpoint.Meta.table

            data = endpoint.to_dict()
            data['fields'] = resource_type.get_type_of_fields(
                list_fields,
                table,
            )
            endpoints.append(data)

        data = {
            'title': self.title,
            'endpoints': sorted(endpoints, key=lambda x: x['name']),
        }

        return json.dumps(data)
290652
def autodocs():
    ""
    build_dir = path('docs/_build')
    index_html = build_dir / 'html/index.html'
    if build_dir.exists():
        build_dir.rmtree()

    with pushd("docs"):
        print "\n*** Generating API doc ***\n"
        sh("sphinx-apidoc -o apidoc -f -T -M ../src/pyrocore")
        sh("sphinx-apidoc -o apidoc -f -T -M $(dirname $(python -c 'import tempita; print(tempita.__file__)'))")
        print "\n*** Generating HTML doc ***\n"
        sh('nohup %s/Makefile SPHINXBUILD="sphinx-autobuild -p %d'
           ' -i \'.*\' -i \'*.log\' -i \'*.png\' -i \'*.txt\'" html >autobuild.log 2>&1 &'
           % (os.getcwd(), SPHINX_AUTOBUILD_PORT))

    for i in range(25):
        time.sleep(2.5)
        pid = watchdog_pid()
        if pid:
            sh("touch docs/index.rst")
            sh('ps {}'.format(pid))
            url = 'http://localhost:{port:d}/'.format(port=SPHINX_AUTOBUILD_PORT)
            print("\n*** Open '{}' in your browser...".format(url))
            break
713074
def documentation_404(self, base_url=None):
        """"""
        base_url = self.base_url if base_url is None else base_url

        def handle_404(request, response, *args, **kwargs):
            url_prefix = request.forwarded_uri[:-1]
            if request.path and request.path != "/":
                url_prefix = request.forwarded_uri.split(request.path)[0]

            to_return = OrderedDict()
            to_return['404'] = ("The API call you tried to make was not defined. "
                                "Here's a definition of the API to help you get going :)")
            to_return['documentation'] = self.documentation(base_url, self.determine_version(request, False),
                                                            prefix=url_prefix)

            if self.output_format == hug.output_format.json:
                response.data = hug.output_format.json(to_return, indent=4, separators=(',', ': '))
                response.content_type = 'application/json; charset=utf-8'
            else:
                response.data = self.output_format(to_return, request=request, response=response)
                response.content_type = self.output_format.content_type

            response.status = falcon.HTTP_NOT_FOUND

        handle_404.interface = True
        return handle_404
490488
function GENERATE_METHOD(name, spec, parent) {
  name = name.replace(/!+$/, '');
  return GENERATE_DOC(spec.description + '\n'
    + '@method ' + name + '\n'
    + (parent ? ('@for ' + parent + '\n') : '@for common\n')
    + _.reduce(spec.params, function(memo, paramSpec, paramName) {
        return memo + '@param {' + GENERATE_TYPE(paramSpec.type) + '} ' + paramName + ' ' + paramSpec.description + '\n'; 
      }, '')
    + ( !_.isEmpty(spec.return) ? ('@return {' + GENERATE_TYPE(spec.return.type) + '} ' + spec.return.description + '\n') : ''));
}
331512
function GENERATE_METHOD(name, spec) {
  var doc = {};
  doc[name] = {
    '!type': 'fn(' + GENERATE_PARAMS(spec.params) + ')' + GENERATE_RETURN(spec.return),
    '!doc': spec.description
  }
  return doc;
}
1056371
def generate_api_key(self):
        
        endpoint = '/'.join((self.server_url, '_api', 'v2', 'api_keys'))
        resp = self.r_session.post(endpoint)
        resp.raise_for_status()
        return response_to_json_dict(resp)
1058557
private function loadDocumentation()
    {
        $this->metrics_documentation = array();

        $idSite = Common::getRequestVar('idSite', 0, 'int');

        if ($idSite < 1) {
            return;
        }

        $apiParameters = array();
        $entityNames = StaticContainer::get('entities.idNames');
        foreach ($entityNames as $entityName) {
            $idEntity = Common::getRequestVar($entityName, 0, 'int');
            if ($idEntity > 0) {
                $apiParameters[$entityName] = $idEntity;
            }
        }

        $report = API::getInstance()->getMetadata($idSite, $this->controllerName, $this->controllerAction, $apiParameters);

        if (empty($report)) {
            return;
        }

        $report = $report[0];

        if (isset($report['metricsDocumentation'])) {
            $this->metrics_documentation = $report['metricsDocumentation'];
        }

        if (isset($report['documentation'])) {
            $this->documentation = $report['documentation'];
        }
    }