Commit Graph

78 Commits

Author SHA1 Message Date
Alexander Fadeev 1813e1996a Fix the 'No such file or directory' error
Problem: build error when `http_theme` is NOT 'openstackdocs'
Cause: `copy_assets` starts copying fonts into non-existing dir.
Measure: mkdir _static/fonts before copying

```
Extension error (os_api_ref):
Handler <function copy_assets at 0x7fd3c902f310> for event
'build-finished' threw an exception (exception: [Errno 2]
No such file or directory: '..../api-ref/build/html/_static/
fonts/glyphicons-halflings-regular.ttf')
```

Change-Id: I70d5455db3bb61060a54202c5e510493c81661d5
2023-02-17 23:03:43 +02:00
Daniel Garcia Moreno 06cd5abff4 Remove deprecated sphinx-testing dependency
This patch replaces the sphinx-testing package using the SphinxTestApp
provided by the Sphinx package.

The sphinx-testing package is deprecated and should be replaced with
the sphinx.testing package that's bundled with Sphinx.

Change-Id: I60b4d1a8b83dc35c394e29d746a2fbb3ff744c1a
2022-10-03 12:36:17 +02:00
Rafael Weingärtner 3d4f056ca3 Fix exception logging
When an exception happens while executing the method `_load_param_file`,
the exception logging `LOG.exception(exc_info=exc)` will generate an
error.

A small snippet to reproduce the issue is the following code:

  from sphinx.util import logging

  LOG = logging.getLogger(__name__)

  try:
      raise Exception("teste")
  except Exception as exc:
      LOG.exception(exc_info=exc)

Which will generate the error:

  Exception: teste

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/home/rafael/git/os-api-ref/os_api_ref/test-logging.py", line 8, in <module>
      LOG.exception(exc_info=exc)
  TypeError: exception() missing 1 required positional argument: 'msg'

  Process finished with exit code 1

With this fix, the exception logging error is solved, and users get a
meaningful message.

Change-Id: Ib3c3e93c283d86b9708c74e60c2ac5762dc2c222
2021-10-21 10:16:39 +01:00
Stephen Finucane fcf44fcfb5 Remove six
There were only two small users. No need to keep the library around for
those.

Change-Id: Iad5d845b46852ce74962a134c8d250142f29c8e3
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-10-21 10:14:26 +01:00
Stephen Finucane 42053b1f92 Drop support for Sphinx < 4.x
Our tests are broken due to changes introduced by Sphinx 4.0 and thus
require some adaptation. Rather than introduce more logic into tests to
handle older versions, simply drop support for older versions of Sphinx.

Change-Id: I2e8ff5cc2e6b4703d7f767fc95b6766d727d8577
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-10-21 10:14:22 +01:00
Stephen Finucane 1e639fd5a2 Replace 'add_stylesheet', 'add_javascript'
We currently see the following warnings when building a doc project
involving os-api-ref:

  RemovedInSphinx40Warning: The app.add_stylesheet() is deprecated.
  Please use app.add_css_file() instead.
  RemovedInSphinx40Warning: The app.add_javascript() is deprecated.
  Please use app.add_js_file() instead.

As the message would suggest, these methods were replaced by
'add_css_file' and 'add_js_file' in commits 3afc72fb [1] and f3168d98
[2], respectively. Both changes were first included in Sphinx 1.8, which
is lower than our current minimum, so there's no need to bump
requirements.

[1] https://github.com/sphinx-doc/sphinx/commit/3afc72fb
[2] https://github.com/sphinx-doc/sphinx/commit/f3168d98

Change-Id: I7f4d772adbcb9d592935b14c430ae3a62a60b6d1
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-12-07 11:21:31 +00:00
Andreas Jaeger 8cb0072adb Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found by updated hacking version.

Change-Id: I4a4ec207f87d3afb58b6427825ce9b3872823008
2020-03-30 12:01:47 +00:00
Stephen Finucane 2a3f53494d Add support for Sphinx v2.1
Come a new Sphinx version, come new breakages. This one is because of
commit 107c20a11f [1], which changed the default centering style of
tables.

[1] https://github.com/sphinx-doc/sphinx/commit/107c20a11f

Change-Id: I1155300828ad0012bd80b7615a0baca121c5e72e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-06-24 16:08:55 +01:00
Stephen Finucane 525eee5a72 Add support for Sphinx 2.0
Sphinx 2.0 switched the default HTML builder from HTML4 to HTML5 [1].
Since some of our tests are validating raw HTML output, this has caused
them to break. We can't drop support for Sphinx < 2.0 yet since Sphinx
2.0 doesn't support Python 2.7, so simply if-else this mofo until such a
time as we _can_ drop support.

[1] https://github.com/sphinx-doc/sphinx/issues/4587

Change-Id: I4631169908e34fa924f5a0a783a94ad9c1215d9f
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-04-25 17:26:50 +01:00
Stephen Finucane c6874c7f72 trivial: Remove unused attribute
This was added in I10d90ac2f702153508bc6e607ed451c089276a4d and doesn't
appear to have been used anywhere. Remove it.

Change-Id: If29f203da9633f9174ed4ba94d70153962d195b9
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-04-01 16:41:51 +01:00
Zuul 3b3734499b Merge "Update hacking version" 2019-01-15 01:05:29 +00:00
Luigi Toscano 8626ce5d88 Generate stable targets rather than random
A random value can still easily hit collision, and at least
one was found easily on the gates (gone with a recheck).
Moreover, the usage of a random target does not allow for ensuring
reproducible builds: the usage of an hash build from the node
content makes sure that the target is stable across different
runs of api-ref generation.

Change-Id: I3fcd8a4e5b0a66c9dbf34f4a4c472f3c93c46bb8
2019-01-11 11:59:16 +01:00
Luigi Toscano 4e56d09daf Fix microversion test: handle different HTML renderings
The rendered HTML changes a bit between beautifulsoup4 4.6.3 and 4.7.1.
A regular expression can handle both cases.

Change-Id: I64d4c56b480d54b50e58141999636b91b5fb4f94
2019-01-11 11:58:11 +01:00
ZhijunWei 0228eb9ae3 Update hacking version
Use latest release 1.1.0 and compatible changes w.r.t pep8

Change-Id: I16071db752ab50d42127dca07d68130fea7474ce
2019-01-06 18:12:47 +08:00
Zuul 6fee36c342 Merge "Fixing duplicate label issue." 2018-12-12 07:01:24 +00:00
Telles Nobrega b23ce2f788 Fixing duplicate label issue.
For projects that have multiple APIs documented simultaneously, if
the labels are the equal on more than one version of the API build
will fail due to duplicate label.
Adding a random number to minimize the chance of duplicate label.

Change-Id: Ic8434ce79630637a878fa64307796be0f3efe6d1
2018-12-11 10:51:51 -03:00
Gergely Csatari d636dddb47 readthedocs.io support
rtd uses 'readthedocs' and 'readthedocssinglehtmllocalmedia' as
builder names. os-api-ref expected 'html' as builder name to
handle the css files correctly.
This change adds the support for the rtd builders.

Change-Id: I21a5144ada79c8c95846ce961169e2505db27a56
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>
2018-12-10 18:15:26 -08:00
Sean McGinnis ba9b0192a3 Update sphinx extension logging
Sphinx 1.6 deprecated using the application object to perform logging
and it will be removed in the upcoming 2.0 release. This updates our
extensions to use the recommended sphinx.util.logging instead.

Change-Id: I1cb9b6cf7fd38ce1ae09e35af0953885a6318082
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2018-10-16 15:14:45 -05:00
Stephen Finucane fd9f284292 tests: Support Sphinx 1.8+
Change-Id: I6ba49b94c6a029746fb284a7e8e7f70c1f070de8
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2018-10-08 10:27:40 +01:00
Stephen Finucane 9cebd346dc Use 'sphinx.util.logging'
This resolves a deprecation warning. It also allows us to stop storing
the 'app' variable just to enable logging.

Change-Id: I53c0f0d5cc61e32a8f1ac1d48816d2c56d82cc41
2018-06-18 14:37:05 +01:00
Graham Hayes d6805491ed General overhaul of testing setup
- Moved to py3 by default
- Moved to testr
- Updated docs venv to match PTI
- Fixed a slight py3 compat issue
- Added py35 and py36 jobs

Change-Id: Id3a8c1c30ecfe9b6538bff6357aecca7ecd0ed81
Signed-off-by: Graham Hayes <gr@ham.ie>
2018-06-18 14:36:12 +01:00
Stephen Finucane 982382a549 Raise warning if top-level value is not a dict
Given the following 'parameters.yaml' file:

  resources_query_granular:
    type: string
    in: query
    required: false
    description: |
      Some description here...
  min_version: 1.22

Clearly 'min_version' is indented at the wrong level. However, the error
message is pretty much useless:

  Exception occurred:
    File "./os_api_ref/__init__.py", line 261, in _check_yaml_sorting
      if value['in'] not in sections:
    TypeError: string indices must be integers, not str

It's obvious we should be saying _what_ is causing this issue. Start
doing this by way of an exception.

Change-Id: If68f82de1e3bf37b1ab89f12adf78e0d8d123674
2018-05-29 15:43:22 +02:00
Ondřej Nový 99b9b75b83 Fix UnicodeDecodeError
When generated Sphinx file is not in ascii, current code fails.

Change-Id: Ie0c2fe56ee64710e81643ec58aec20dd6d7ec042
2017-10-31 22:14:21 +01:00
Jenkins 0cd27677a4 Merge "Clear description for max_version field" 2017-09-19 18:45:44 +00:00
Stephen Finucane 3d8f7ef4a1 doc: Remove deprecated call to sphinx.util.compat
This call generates the following deprecation warning:

  RemovedInSphinx17Warning: sphinx.util.compat.Directive is deprecated
  and will be removed in Sphinx 1.7, please use docutils' instead.

Resolve this.

Change-Id: I1083d3d6f3e646249f187a1bdade61eecc93c7e0
2017-08-29 15:20:58 +01:00
ghanshyam 1f71845ede Clear description for max_version field
Currently max_version field shows text as
"Deprecated in version %s" which seems confusing to show
deprecated fields vs removed fields.

For example: if any element is removed in x version, then we
tag that element in parameter.yaml with max_version: x-1. api-ref shows
that element as "Deprecated in version x-1" which seems confusing on
below interpretation:
- is that element deprecated in x-1 version?
- is that element only deprecated in x-1 version not removed?

But actually that element is removed in x and only available till x-1 version.

- https://developer.openstack.org/api-ref/compute/?expanded=evacuate-server-evacuate-action-detail

This commit try to describe max_version filed in more clear way.

Change-Id: I388c6e27c3d15e3bee645b7b56f8142e2f16d3d6
2017-06-29 02:48:13 +00:00
Jenkins a67ed2f235 Merge "Removes unnecessary utf-8 encoding" 2017-06-13 19:46:05 +00:00
Sean Dague ce1252fcfc Fix for sphinx 1.6.2
This changes things to work on sphinx 1.6.2, should still work on
sphinx 1.5.1.

Change-Id: I6547877ad46d008616458a5f3b52105ab4f55c28
2017-06-13 15:22:12 -04:00
gengchc2 a9c8604bb8
Replaces yaml.load() with yaml.safe_load()
Python objects returned with Yaml.load() may be dangerous if you receive
a YAML document from an untrusted source such as the Internet.
The function yaml.safe_load() limits this ability to simple Python
objects like integers or lists.

In ordered_load we're adding a custom class so we have to use yaml.load.
In order to make it safe, set the base class to SafeLoader instead of
Loader.

Reference:
https://security.openstack.org/guidelines/dg_avoid-dangerous-input-parsing-libraries.html

Co-Authored-By: Monty Taylor <mordred@inaugust.com>
Change-Id: I3d5df9898c72c59ddab0ac7562b953e91f470220
2017-05-12 14:12:05 -05:00
Monty Taylor 32101d84c1
Update tests for more recent sphinx
The html output now uses a more compact form for empty col elements.
Update the tests to account for this.

Change-Id: I055254463e48cc8fdd44c4de7c39595a574afa47
2017-05-12 14:07:22 -05:00
Jenkins a01f103f24 Merge "Import httplib from six to support Python 3" 2017-01-31 16:49:14 +00:00
Jenkins ac2ef89c64 Merge "Fix anchor link setting url bar" 2017-01-19 13:20:24 +00:00
Jenkins a4122e3ed8 Merge "Removes unnecessary utf-8 encoding" 2017-01-18 20:52:33 +00:00
Jenkins 4636482fa4 Merge "Add test for missing path params" 2017-01-18 20:52:27 +00:00
Sean Dague d521256ccf Fix anchor link setting url bar
Add an explicit onclick action for anchor links so that they set the
urlbar correctly. This long standing issue really sucks in sending
around links to people from API sites.

Change-Id: I449399836d2f327188b659a266b2e860e3ebb462
2017-01-18 14:12:49 -05:00
Karen Bradshaw 2004c987ac detail/close button, bug #1618955
When ShowAll button is selected, close
button text was grayed out.
Update CSS to display readable button text, and match
the current behaviour of the detail/close button
when a single section is displayed.

Change-Id: Icd40ecae8f5007bbf3546b678a6f5f6081e89bc6
2017-01-18 08:59:06 -05:00
Cao Xuan Hoang be63992f7b Removes unnecessary utf-8 encoding
The following file(s) added utf-8 encoding but never used. So we can
remove them at all.

os_api_ref/tests/test_warnings.py
os_api_ref/tests/test_os_api_ref.py
os_api_ref/tests/test_microversions.py
os_api_ref/tests/test_basic_example.py
os_api_ref/tests/base.py
os_api_ref/__init__.py

Change-Id: If08e1b00f777a146e2c582f5a194e022a215066e
2017-01-16 10:14:24 +07:00
shashi.kant cca9e716fd Removes unnecessary utf-8 encoding
Change-Id: I13645eff9c28c5742b4558d9197af80268d25bee
2017-01-12 11:12:44 +00:00
Dmitry Shachnev f30d53cda0 Add compatibility with docutils 0.13
In docutils 0.13.1, the get_column_widths method of Table directive
returns a tuple, where the widths array is the second item.

Also, get_column_widths now has a “if type(self.widths) == list” check,
so use the list syntax when setting the widths property.

Change-Id: I9888a649313c60257ce6dfc46cfbd2dcbf7ac189
2017-01-08 00:20:36 +03:00
Yuval Brik 8aaa668262 Import httplib from six to support Python 3
In Python 3, httplib moved to http.client.
Use six in order to import the correct library on both Python 2 and
Python 3.

Change-Id: I6f43faf453809eed3f2e88fd587e941c80204793
Closes-Bug: #1623447
2016-11-06 16:12:55 +02:00
Karen Bradshaw 9c2d634246 Add test for missing path params
Add warning and test for missing path parameters.

Change-Id: I8686006339b82ed5465dd8e4d3a8b15f85ee897c
2016-10-31 12:03:01 -04:00
Graham Hayes 57c111888e microversion selector - dropdown
This does a few things:

* Change from button list to a select combo box.
** This allows users to type the number they want
* Add the ablity to tag versions to releases
** E.G. Say mitaka was released with 2.27, it will
   show in the list as "2.27 - Mitaka".
** This currently set as a config option in
   conf.py as a dict like:

  os_api_ref_release_microversions = {
      '2.27' : 'mitaka',
      '2.10': 'liberty'
  }

* Uses https://github.com/danielfarrell/bootstrap-combobox
** Apache Licenced

Change-Id: Ica7dd55cdbf413f03ea635aefb627a705132a73e
2016-10-28 12:07:57 +02:00
Jenkins db3e83584c Merge "Expand width of API Site" 2016-09-22 20:21:54 +00:00
Sean Dague a22ecf2e40 remove padding-top for endpoint-container
This causes a really odd vertical alignment issue. If we remove it
then the entire API line is vertically aligned.

Change-Id: I3fc2d4b234843ec226d75d5d4dd79055d33645b6
2016-08-29 09:25:29 -04:00
Jenkins 2c6dd1bc6c Merge "Add color for COPY label" 2016-08-29 13:16:28 +00:00
Graham Hayes 8d31f26db9 Expand width of API Site
Change-Id: I3576012ebee21222e3f30f3310aeef01ca7e605b
2016-08-23 15:46:12 +01:00
Graham Hayes 916db5d19b openstackdocstheme integration
changes the output to be compatible with the new
openstackdocs theme

Change-Id: I10d90ac2f702153508bc6e607ed451c089276a4d
2016-08-19 16:22:15 +01:00
Karen Bradshaw f9241b160e Add color for COPY label
Add colors in css for COPY label.

Change-Id: Ic5c61d286c071c2fc45a5d215bef4f7344d490f8
2016-08-04 13:25:12 -04:00
Graham Hayes b100d1542f Change Layout of Path + Sub Title
With very long URI paths the wrapping either
looks weird or there is no charecter for it to
wrap on.

This moves the URI to its own line, and moves some
of the other elements aroud slightly.

Also changes the font of the subtitle to make it more apparent.

Change-Id: I36e7420224f69eaa5f4dceb18d910b40377b76c4
2016-08-02 14:52:27 +01:00
Jenkins 51a1f98c15 Merge "HTTP Response Code Table" 2016-07-25 20:00:52 +00:00