Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 42fd342

Browse files
authored
Merge pull request #1180 from apiaryio/honzajavorek/remove-complexity
Hardcode the version to 'latest' in the docs
2 parents 4eaca26 + 527530d commit 42fd342

File tree

2 files changed

+13
-65
lines changed

2 files changed

+13
-65
lines changed

docs/conf.py

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import sys
33
import re
44
import json
5-
import subprocess
65
import urllib.request
76

87
from sphinx.errors import SphinxError
@@ -21,24 +20,6 @@
2120
# Explicitly put the extensions directory to Python path
2221
sys.path.append(os.path.abspath('_extensions'))
2322

24-
# Detect whether the build happens on ReadTheDocs
25-
IS_READTHEDOCS = os.environ.get('READTHEDOCS') == 'True'
26-
27-
# Specify paths
28-
docs_dir = os.path.dirname(__file__)
29-
project_dir = os.path.join(docs_dir, '..')
30-
node_modules_bin_dir = os.path.join(project_dir, 'node_modules', '.bin')
31-
32-
# Install all npm dependencies if on ReadTheDocs. This requires the latest
33-
# ReadTheDocs build image, which supports Node.js out of the box. This is
34-
# specified in the readthedocs.yml in the root of the project.
35-
if IS_READTHEDOCS:
36-
subprocess.check_call('npm install', cwd=project_dir, shell=True)
37-
38-
# Load package.json data
39-
with open(os.path.join(project_dir, 'package.json')) as f:
40-
package_json = json.load(f)
41-
4223

4324
# -- General configuration ------------------------------------------------
4425

@@ -66,42 +47,10 @@
6647
copyright = 'Apiary Czech Republic, s.r.o.'
6748
author = 'Apiary'
6849

69-
# The version info for the project you're documenting, acts as replacement for
70-
# |version| and |release|, also used in various other places throughout the
71-
# built documents.
72-
def get_release():
73-
try:
74-
# Is internet available? this is to be able to generate docs
75-
# e.g. in train without internet connection
76-
urllib.request.urlopen('https://www.npmjs.com/package/dredd', timeout=3)
77-
except urllib.request.URLError as e:
78-
if IS_READTHEDOCS:
79-
# ReadTheDocs have problem to connect to npm, fail fast
80-
raise SphinxError('Could not determine Dredd version: {}'.format(e))
81-
else:
82-
# Offline local development, use dummy release number
83-
return package_json['version']
84-
else:
85-
# Online, ask Semantic Release what would be the next version
86-
sem_rel_bin = os.path.join(node_modules_bin_dir, 'semantic-release')
87-
sem_rel_output = subprocess.getoutput('{} pre'.format(sem_rel_bin))
88-
match = re.search(r'determined version (\d+\.\d+\.\d+)', sem_rel_output, re.I)
89-
if match:
90-
# Semantic Release would use this version number
91-
return match.group(1)
92-
93-
# Semantic Release wasn't able to determine a new version number,
94-
# either because of some error or because there are no changes which
95-
# would bump the version number. Stick to the latest released version.
96-
return subprocess.getoutput('npm view dredd version').strip()
97-
98-
# The full version, including alpha/beta/rc tags.
99-
release = get_release()
100-
if not re.match(r'\d+\.\d+\.\d+', release):
101-
raise SphinxError("'{}' does not look like version number".format(release))
102-
103-
# The short X.Y version.
104-
version = release
50+
# The project version (2.6) and release (2.6.0rc1) numbers. Figuring this
51+
# out for Dredd is tricky (because of Semantic Release), so it's hardcoded.
52+
version = 'latest'
53+
release = 'latest'
10554

10655
# List of patterns, relative to source directory, that match files and
10756
# directories to ignore when looking for source files.

docs/internals.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ The Travis CI build uses following commands to deliver coverage reports:
178178

179179
The first mentioned command does following:
180180

181-
1. Uses `istanbul <https://github.com/gotwarlost/istanbul>`__ to instrument the JavaScript code
182-
2. Runs the tests on the instrumented code using Mocha with a special lcov reporter, which gives us information about which lines were executed in the standard lcov format
183-
3. Because some integration tests execute the ``bin/dredd`` script in a subprocess, we collect the coverage stats also in this file. The results are appended to a dedicated lcov file
184-
4. All lcov files are then merged into one using the `lcov-result-merger <https://github.com/mweibel/lcov-result-merger>`__ utility and sent to Coveralls
181+
#. Uses `istanbul <https://github.com/gotwarlost/istanbul>`__ to instrument the JavaScript code
182+
#. Runs the tests on the instrumented code using Mocha with a special lcov reporter, which gives us information about which lines were executed in the standard lcov format
183+
#. Because some integration tests execute the ``bin/dredd`` script in a subprocess, we collect the coverage stats also in this file. The results are appended to a dedicated lcov file
184+
#. All lcov files are then merged into one using the `lcov-result-merger <https://github.com/mweibel/lcov-result-merger>`__ utility and sent to Coveralls
185185

186186
Hand-made combined Mocha reporter is used to achieve running tests and collecting coverage at the same time.
187187

@@ -217,18 +217,17 @@ Even though alternatives exist (dredd.readthedocs.io, dredd.rtfd.io, or dredd.io
217217
Building documentation locally
218218
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
219219

220-
The documentation is built by `Sphinx <http://www.sphinx-doc.org/>`__. To render it on your computer, you need `Python 3 <https://www.python.org/>`__ and `Node.js <http://nodejs.org/>`__.
220+
The documentation is built by `Sphinx <http://www.sphinx-doc.org/>`__. To render it on your computer, you need `Python 3 <https://www.python.org/>`__.
221221

222-
1. Make sure ``node`` is an executable and ``npm install`` has been done for the Dredd directory.
223-
2. `Get Python 3 <https://www.python.org/downloads/>`__. `ReadTheDocs <https://readthedocs.org/>`__ build the documentation with Python 3.6, so make sure you have this version.
224-
3. Create a `virtual environment <https://docs.python.org/3/library/venv.html>`__ and activate it:
222+
#. `Get Python 3 <https://www.python.org/downloads/>`__. `ReadTheDocs <https://readthedocs.org/>`__ build the documentation with Python 3.6, so make sure you have this version.
223+
#. Create a `virtual environment <https://docs.python.org/3/library/venv.html>`__ and activate it:
225224

226225
.. code-block:: shell
227226
228227
python3 -m venv ./venv
229228
source ./venv/bin/activate
230229
231-
4. Install dependencies for the docs:
230+
#. Install dependencies for the docs:
232231

233232
.. code-block:: shell
234233
@@ -248,7 +247,7 @@ Now you can use following commands:
248247
Installation on ReadTheDocs
249248
~~~~~~~~~~~~~~~~~~~~~~~~~~~
250249

251-
The final documentation gets published by `ReadTheDocs <https://readthedocs.org/>`__. Because the documentation needs some of the npm dependencies installed and ReadTheDocs do not support this in their default build environment, we force their latest build image, which includes Node.js out of the box, in the ``readthedocs.yml``. In the Sphinx' configuration file, ``docs/conf.py``, we make sure ``npm install`` is executed on ReadTheDocs.
250+
The final documentation gets published by `ReadTheDocs <https://readthedocs.org/>`__. We force their latest build image in the ``readthedocs.yml`` to get Python 3.
252251

253252

254253
Writing documentation

0 commit comments

Comments
 (0)