Beispiel #1
0
def _update_readme(api: type, path: str = DEFAULT_README_PATH):
    r = SimpleRecorder()
    h = Helper(output=r)
    h.help(api)
    readme = f'''# Companies' House Python API
Simply create an API client as an instance of CompaniesHouseAPI:
```
from companies_house.api import CompaniesHouseAPI
ch = CompaniesHouseAPI(api_key)
```

This will give you access to all the functions registered in the API. For full reference, including the available
additional arguments (which can be passed as kwargs), please
refer to [the official API documentation](https://developer.companieshouse.gov.uk/api/docs/).

The Python wrapper additionally gives you the following functionality for each function:
* `flatten`: Flatten the returned `dict` (to allow use in flat files, pandas etc.)
* `follow_links`: API resources are linked by a `links` attribute. If  you set `follow_links` to true, those are
    automatically followed and merged into the main object, to form a deeper, more comprehensive object. Use with care
    as there are currently no checks for recursion!

```
help(CompaniesHouseAPI)
```

```
{r.text}
```
When the API has changed,
run `update.py` to re-download the API definition.
When running the API, this documentation is updated automatically.
'''
    with open(path, 'w') as f:
        f.write(readme)
Beispiel #2
0
    def html_topicpage(topic):
        """Topic or keyword help page."""
        buf = io.StringIO()
        htmlhelp = Helper(buf, buf)
        contents, xrefs = htmlhelp._gettopic(topic)
        if topic in htmlhelp.keywords:
            title = 'Keyword'
        else:
            title = 'Topic'
        heading = html.heading(title)
        contents = '<pre>%s</pre>' % html.markup(contents)
        contents = html.bigsection(topic, contents, css_class="topics")
        if xrefs:
            xrefs = sorted(xrefs.split())

            def bltinlink(name):
                return '<a href="topic?key=%s">%s</a>' % (name, name)

            xrefs = html.multicolumn(xrefs, bltinlink)
            xrefs = html.html_section('Related help topics: ',
                                      xrefs,
                                      css_class="topics")
        return ('%s %s' % (title, topic), ''.join((heading, contents, xrefs)))