Skip to content

Commit 648731c

Browse files
committed
Multi version support
1 parent 854b5f3 commit 648731c

File tree

7 files changed

+92
-75
lines changed

7 files changed

+92
-75
lines changed

__init__.py

Whitespace-only changes.

_themes/conan/layout.html

+1-7
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,11 @@
105105
{% endif %}
106106
</a>
107107

108-
{% if theme_display_version %}
109-
{%- set nav_version = version %}
110-
{% if READTHEDOCS and current_version %}
111-
{%- set nav_version = current_version %}
112-
{% endif %}
113108
{% if nav_version %}
114109
<div class="version">
115-
{{ nav_version }}
110+
{{ current_version }}
116111
</div>
117112
{% endif %}
118-
{% endif %}
119113

120114
{% include "searchbox.html" %}
121115

_themes/conan/theme.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ collapse_navigation = False
1111
display_version = True
1212
navigation_depth = 4
1313
prev_next_buttons_location = bottom
14-
base_url =
14+
base_url =

_themes/conan/versions.html

+9-23
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
1-
{% if READTHEDOCS %}
21
{# Add rst-badge after rst-versions for small badge style. #}
32
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
43
<span class="rst-current-version" data-toggle="rst-current-version">
5-
<span class="fa fa-book"> Read the Docs</span>
6-
v: {{ current_version }}
4+
<!--<span class="fa fa-pencil-square-o"> Other versions:</span> -->
5+
Version: {{ current_version }}
76
<span class="fa fa-caret-down"></span>
87
</span>
98
<div class="rst-other-versions">
109
<dl>
1110
<dt>{{ _('Versions') }}</dt>
12-
{% for slug, url in versions %}
13-
<dd><a href="{{ url }}">{{ slug }}</a></dd>
11+
{% for slug, the_version in versions.items() %}
12+
{% if the_version == "latest" %}
13+
<dd><a href="/en/latest/index.html">{{ current_version }}</a></dd>
14+
{% else %}
15+
<dd><a href="/en/{{ the_version }}/index.html">{{ the_version }}</a></dd>
16+
{% endif %}
1417
{% endfor %}
1518
</dl>
16-
<dl>
17-
<dt>{{ _('Downloads') }}</dt>
18-
{% for type, url in downloads %}
19-
<dd><a href="{{ url }}">{{ type }}</a></dd>
20-
{% endfor %}
21-
</dl>
22-
<dl>
23-
<dt>{{ _('On Read the Docs') }}</dt>
24-
<dd>
25-
<a href="//{{ PRODUCTION_DOMAIN }}/projects/{{ slug }}/?fromdocs={{ slug }}">{{ _('Project Home') }}</a>
26-
</dd>
27-
<dd>
28-
<a href="//{{ PRODUCTION_DOMAIN }}/builds/{{ slug }}/?fromdocs={{ slug }}">{{ _('Builds') }}</a>
29-
</dd>
30-
</dl>
3119
<hr/>
32-
{% trans %}Free document hosting provided by <a href="http://www.readthedocs.org">Read the Docs</a>.{% endtrans %}
33-
3420
</div>
3521
</div>
36-
{% endif %}
22+
3723

conf.py

+22-9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@
3535
'conan',
3636
]
3737

38+
# The short X.Y version.
39+
version = "1.3"
40+
# The full version, including alpha/beta/rc tags.
41+
release = u'1.3.1'
42+
versions_dict = {"feature/multi_versions": "latest",
43+
"release/1.2.3": "1.2"}
44+
45+
46+
# The version info for the project you're documenting, acts as replacement for
47+
# |version| and |release|, also used in various other places throughout the
48+
# built documents.
49+
#
50+
51+
52+
html_context = {
53+
"versions": versions_dict,
54+
"current_version": version
55+
}
56+
3857
# Add any paths that contain templates here, relative to this directory.
3958
templates_path = ['_templates']
4059

@@ -54,14 +73,8 @@
5473
copyright = u'2016-2018, JFrog'
5574
author = u'conan'
5675

57-
# The version info for the project you're documenting, acts as replacement for
58-
# |version| and |release|, also used in various other places throughout the
59-
# built documents.
60-
#
61-
# The short X.Y version.
62-
version = u'1.3'
63-
# The full version, including alpha/beta/rc tags.
64-
release = u'1.3.1'
76+
77+
6578

6679
# The language for content autogenerated by Sphinx. Refer to documentation
6780
# for a list of supported languages.
@@ -122,7 +135,7 @@
122135
# further. For a list of options available for each theme, see the
123136
# documentation.
124137
html_theme_options = {
125-
"base_url": "http://docs.conan.io/en/latest/"
138+
"base_url": "http://docs.conan.io/en/latest/",
126139
}
127140

128141
# Add any paths that contain custom themes here, relative to this directory.

gh_pages.py

+38-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
import os
33
import shutil
4+
import tempfile
5+
6+
from conf import versions_dict
47

58

69
def copytree(src, dst, symlinks=False, ignore=None):
@@ -19,30 +22,51 @@ def call(command, ignore_error=False):
1922
raise Exception("Command failed: %s" % command)
2023

2124

22-
tmp_dir = os.getenv("CONANDOCS_TMP_DIR", "/tmp/docs")
2325
excluded_files = (".git", "CNAME", "index.html")
2426

25-
if __name__ == "__main__":
27+
28+
def clean_gh_pages():
29+
call("git checkout gh-pages")
30+
call("git pull origin gh-pages")
31+
if os.path.exists("en"):
32+
shutil.rmtree("en")
33+
34+
35+
def build_and_copy(branch, folder_name):
36+
call("git checkout %s" % branch)
2637

2738
call("make html")
28-
call("make linkcheck")
39+
# call("make linkcheck")
40+
tmp_dir = tempfile.mkdtemp()
2941
if os.path.exists(tmp_dir):
3042
shutil.rmtree(tmp_dir)
3143
os.mkdir(tmp_dir)
3244

3345
copytree("_build/html/", tmp_dir)
46+
shutil.rmtree("_build")
47+
48+
# Go to deploy branch, copy new files and commit
3449
call("git checkout gh-pages")
35-
call("git pull origin gh-pages")
50+
if not os.path.exists("en"):
51+
os.mkdir("en")
3652

37-
if os.path.exists("en"):
38-
shutil.rmtree("en")
53+
version_folder = "en/%s" % folder_name
54+
if os.path.exists(version_folder):
55+
shutil.rmtree(version_folder)
3956

40-
os.mkdir("en")
41-
os.mkdir("en/latest")
42-
43-
copytree(tmp_dir, "en/latest")
57+
os.mkdir(version_folder)
58+
copytree(tmp_dir, version_folder)
4459
call("git add -A .")
45-
call("git commit -m 'deploying web'", ignore_error=True)
46-
call("git push origin gh-pages", ignore_error=True)
47-
call("git checkout master")
48-
print("PUSHED!")
60+
call("git commit -m 'committed version %s'" % folder_name, ignore_error=True)
61+
62+
63+
if __name__ == "__main__":
64+
65+
clean_gh_pages()
66+
67+
for branch, folder_name in versions_dict.items():
68+
build_and_copy(branch, folder_name)
69+
70+
#call("git push origin gh-pages", ignore_error=True)
71+
72+
print("PUSH skipped, make sure all is ok and 'git push origin gh-pages'")

howtos/vs2017_cmake.rst

+21-21
Original file line numberDiff line numberDiff line change
@@ -165,28 +165,28 @@ All you need is to right click on your `conanfile.py`-> Configure Tasks (see the
165165
.. code-block:: text
166166
:emphasize-lines: 7,9,16,18
167167
168-
{
169-
"tasks": [
170-
{
171-
"taskName": "conan install debug",
172-
"appliesTo": "conanfile.py",
173-
"type": "launch",
174-
"command": "${env.COMSPEC}",
175-
"args": [
176-
"conan install ${file} -s build_type=Debug -if C:/Users/user/CMakeBuilds/4c2d87b9-ec5a-9a30-a47a-32ccb6cca172/build/x64-Debug/"
177-
]
178-
},
179168
{
180-
"taskName": "conan install release",
181-
"appliesTo": "conanfile.py",
182-
"type": "launch",
183-
"command": "${env.COMSPEC}",
184-
"args": [
185-
"conan install ${file} -s build_type=Release -if C:/Users/user/CMakeBuilds/4c2d87b9-ec5a-9a30-a47a-32ccb6cca172/build/x64-Release/"
186-
]
169+
"tasks": [
170+
{
171+
"taskName": "conan install debug",
172+
"appliesTo": "conanfile.py",
173+
"type": "launch",
174+
"command": "${env.COMSPEC}",
175+
"args": [
176+
"conan install ${file} -s build_type=Debug -if C:/Users/user/CMakeBuilds/4c2d87b9-ec5a-9a30-a47a-32ccb6cca172/build/x64-Debug/"
177+
]
178+
},
179+
{
180+
"taskName": "conan install release",
181+
"appliesTo": "conanfile.py",
182+
"type": "launch",
183+
"command": "${env.COMSPEC}",
184+
"args": [
185+
"conan install ${file} -s build_type=Release -if C:/Users/user/CMakeBuilds/4c2d87b9-ec5a-9a30-a47a-32ccb6cca172/build/x64-Release/"
186+
]
187+
}
188+
],
189+
"version": "0.2.1"
187190
}
188-
],
189-
"version": "0.2.1"
190-
}
191191
192192
Then just right click on your *conanfile.py* and launch your ``conan install`` and regenerate your *CMakeLists.txt*.

0 commit comments

Comments
 (0)