Skip to content

Commit c2b684f

Browse files
authored
Add support for autodoc in develop2 (#2492)
* use conan themen * add autodocs * update ci * test autodoc * wip * wip * install colorama * mock * wip * add comment * use conanio/ci-docs * add api structure * wip * add experimental note
1 parent 0ab2d19 commit c2b684f

38 files changed

+525
-14
lines changed

.ci/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
FROM python:slim
1+
FROM conanio/ci-docs
22

33
COPY requirements.txt /tmp/
44

5-
RUN apt-get update \
6-
&& apt-get install -y enchant-2 git make latexmk texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra \
7-
&& pip3 install --requirement /tmp/requirements.txt
5+
RUN pip3 install --requirement /tmp/requirements.txt
86

.ci/test.jenkins

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
node('Linux') {
44
String alphaReleaseBranch = 'release/2.0.0-alpha'
55
boolean publishDocs = env.BRANCH_NAME == alphaReleaseBranch
6+
def targetBranch = env.CHANGE_BRANCH
7+
8+
// We also have to clone conan sources for the sphinx autodoc extension
9+
def conanBranch = (targetBranch == alphaReleaseBranch) ? 'release/2.0-alpha' : 'develop2'
10+
def conan_repo_url = 'https://github.com/conan-io/conan.git'
11+
echo "Docs target branch: ${targetBranch}"
12+
echo "Conan target branch: ${conanBranch}"
613

714
stage('Clone sources') {
815
checkout scm
16+
def cloneConan = "git clone --single-branch -b ${conanBranch} --depth 1 ${conan_repo_url} conan_sources"
17+
sh(script: cloneConan)
918
}
1019

1120
def image = null
@@ -16,17 +25,20 @@ node('Linux') {
1625
stage('Test build') {
1726
parallel html: {
1827
image.inside {
19-
sh 'make html'
28+
// for some reason even adding this to autodoc_mock_imports
29+
// does not work, se we have to install the real dependency
30+
sh(script: 'pip3 install colorama')
31+
sh(script: 'make html')
2032
}
2133
},
2234
pdf: {
2335
image.inside {
24-
sh 'make latex'
36+
sh(script: 'make latex')
2537
}
2638
},
2739
spelling: {
2840
image.inside {
29-
sh 'make spelling'
41+
sh(script: 'make spelling')
3042
}
3143
},
3244
linkcheck: {

conf.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@
1818
from shutil import copyfile
1919
import json
2020

21+
# path to the conan_sources, they must be cloned to the branch
22+
# that we are building the docs for
23+
# if building the docs in local, point this to the local conan_sources
24+
25+
path_to_conan_sources = './conan_sources'
26+
2127
# If extensions (or modules to document with autodoc) are in another directory,
2228
# add these directories to sys.path here. If the directory is relative to the
2329
# documentation root, use os.path.abspath to make it absolute, like shown here.
2430

25-
sys.path.insert(0, os.path.abspath('./_themes'))
31+
sys.path.insert(0, os.path.abspath(path_to_conan_sources))
32+
2633

2734

2835
# -- General configuration ------------------------------------------------
@@ -35,12 +42,21 @@
3542
# ones.
3643
extensions = [
3744
'sphinx.ext.todo',
38-
'conan',
3945
'sphinxcontrib.spelling',
4046
'sphinx_sitemap',
4147
'notfound.extension',
48+
'sphinx.ext.autodoc',
4249
]
4350

51+
# autodoc configuration
52+
add_module_names = False
53+
autoclass_content = 'both'
54+
autodoc_mock_imports = ["PyJWT", "requests", "urllib3", "PyYAML",
55+
"patch-ng", "fasteners", "six", "node-semver", "distro",
56+
"pygments", "tqdm", "Jinja2", "MarkupSafe", "Jinja2",
57+
"python-dateutil", "configparse", "patch_ng", "yaml", "semver", "dateutil"]
58+
59+
4460
# The short X.Y version.
4561
version = "2.0-alpha"
4662
# The full version, including alpha/beta/rc tags.
@@ -104,7 +120,7 @@
104120

105121
# List of patterns, relative to source directory, that match files and
106122
# directories to ignore when looking for source files.
107-
exclude_patterns = ['_build', '**/site-packages']
123+
exclude_patterns = ['_build', '**/site-packages', 'conan_sources/**.rst']
108124

109125
# The reST default role (used for this markup: `text`) to use for all
110126
# documents.
@@ -134,14 +150,11 @@
134150
todo_include_todos = True
135151

136152

137-
# -- Options for HTML output ----------------------------------------------
138-
import conan
139-
140153
# The theme to use for HTML and HTML Help pages. See the documentation for
141154
# a list of builtin themes.
142155
# html_theme = 'sphinx_rtd_theme'
143156
html_theme = "conan"
144-
html_theme_path = conan.get_html_theme_path()
157+
html_theme_path = ["_themes"]
145158

146159

147160
# Theme options are theme-specific and customize the look and feel of a theme

reference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Reference
99

1010
reference/commands
1111
reference/python_api
12+
reference/tools

reference/python_api.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
Python API
22
==========
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
python_api/ConanAPIV2
8+
python_api/RemotesAPI
9+
python_api/SearchAPI
10+
python_api/ListAPI
11+
python_api/ProfilesAPI
12+
python_api/InstallAPI
13+
python_api/GraphAPI
14+
python_api/ExportAPI
15+
python_api/RemoveAPI
16+
python_api/ConfigAPI
17+
python_api/NewAPI
18+
python_api/UploadAPI
19+
python_api/DownloadAPI

reference/python_api/ConanAPIV2.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Conan API Reference
2+
===================
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.conan_api
7+
8+
.. autoclass:: ConanAPIV2
9+
:members:
10+
11+
12+
Read more
13+
---------
14+
15+
- Creating Conan custom commands
16+
- ...
17+

reference/python_api/ConfigAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Config API
2+
==========
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.config
7+
8+
.. autoclass:: ConfigAPI
9+
:members:

reference/python_api/DownloadAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Download API
2+
============
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.download
7+
8+
.. autoclass:: DownloadAPI
9+
:members:

reference/python_api/ExportAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Export API
2+
==========
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.export
7+
8+
.. autoclass:: ExportAPI
9+
:members:

reference/python_api/GraphAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Graph API
2+
=========
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.graph
7+
8+
.. autoclass:: GraphAPI
9+
:members:

reference/python_api/InstallAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Install API
2+
===========
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.install
7+
8+
.. autoclass:: InstallAPI
9+
:members:

reference/python_api/ListAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
List API
2+
========
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.list
7+
8+
.. autoclass:: ListAPI
9+
:members:

reference/python_api/NewAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
New API
2+
=======
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.new
7+
8+
.. autoclass:: NewAPI
9+
:members:

reference/python_api/ProfilesAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Profiles API
2+
============
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.profiles
7+
8+
.. autoclass:: ProfilesAPI
9+
:members:

reference/python_api/RemotesAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Remotes API
2+
===========
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.remotes
7+
8+
.. autoclass:: RemotesAPI
9+
:members:

reference/python_api/RemoveAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Remove API
2+
==========
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.remove
7+
8+
.. autoclass:: RemoveAPI
9+
:members:

reference/python_api/SearchAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Search API
2+
==========
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.search
7+
8+
.. autoclass:: SearchAPI
9+
:members:

reference/python_api/UploadAPI.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Upload API
2+
==========
3+
4+
.. include:: api_warning.rst
5+
6+
.. currentmodule:: conan.api.subapi.upload
7+
8+
.. autoclass:: UploadAPI
9+
:members:

reference/python_api/api_warning.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. warning::
2+
The Conan API is experimental and subject to breaking changes.

reference/tools.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.. _conan_tools:
2+
3+
tools
4+
=====
5+
6+
Tools are all things that can be imported and used in Conan recipes.
7+
8+
The import path is always like:
9+
10+
.. code-block:: python
11+
12+
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake
13+
form conan.tools.microsoft import MSBuildToolchain, MSBuildDeps, MSBuild
14+
15+
16+
The main guidelines are:
17+
18+
- Everything that recipes can import belong to ``from conan.tools``. Any other thing is private implementation
19+
and shouldn't be used in recipes.
20+
- Only documented, public (not preceded by ``_``) tools can be used in recipes.
21+
22+
23+
Contents:
24+
25+
.. toctree::
26+
:maxdepth: 2
27+
28+
tools/cmake
29+
tools/env
30+
tools/build
31+
tools/files

reference/tools/build.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. _conan_tools_build:
2+
3+
conan.tools.build
4+
=================
5+
6+
conan.tools.build.cross_building()
7+
----------------------------------
8+
9+
.. currentmodule:: conan.tools.build.cross_building
10+
11+
.. autofunction:: cross_building

reference/tools/cmake.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. _conan_tools_cmake:
2+
3+
conan.tools.cmake
4+
=================
5+
6+
.. toctree::
7+
:maxdepth: 2
8+
9+
cmake/cmakedeps
10+
cmake/cmaketoolchain
11+
cmake/cmake
12+
cmake/cmake_layout

reference/tools/cmake/cmake.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. _conan-cmake-build-helper:
2+
3+
CMake
4+
-----
5+
6+
Reference
7+
=========
8+
9+
.. currentmodule:: conan.tools.cmake.cmake
10+
11+
.. autoclass:: CMake
12+
:members:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. _cmake_layout:
2+
3+
cmake_layout
4+
------------
5+
6+
.. currentmodule:: conan.tools.cmake.layout
7+
8+
.. autofunction:: cmake_layout

reference/tools/cmake/cmakedeps.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.. _CMakeDeps:
2+
3+
CMakeDeps
4+
---------
5+
6+
Reference
7+
=========
8+
9+
.. currentmodule:: conan.tools.cmake.cmakedeps.cmakedeps
10+
11+
.. autoclass:: CMakeDeps
12+
:members:
13+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CMakeToolchain
2+
--------------
3+
4+
Reference
5+
=========
6+
7+
.. currentmodule:: conan.tools.cmake.toolchain.toolchain
8+
9+
.. autoclass:: CMakeToolchain
10+
:members:

0 commit comments

Comments
 (0)