Skip to content

Commit d90b205

Browse files
authored
Fix docstrings from Conan API and some tools (#10983)
* fix docstrings * fixes * minor changes * more fixes * more fixes...
1 parent 6b3c73a commit d90b205

File tree

10 files changed

+98
-96
lines changed

10 files changed

+98
-96
lines changed

conan/api/subapi/graph.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ def load_root_consumer_conanfile(self, path, profile_host, profile_build,
4747
@api_method
4848
def load_root_test_conanfile(self, path, tested_reference, profile_host, profile_build,
4949
update=None, remotes=None, lockfile=None):
50-
"""
51-
create and initialize a root node from a test_package/conanfile.py consumer
52-
@param lockfile: Might be good to lock python-requires, build-requires
53-
@param path: The full path to the test_package/conanfile.py being used
54-
@param tested_reference: The full RecipeReference of the tested package
55-
@param profile_host:
56-
@param profile_build:
57-
@param update:
58-
@param remotes:
59-
@return: a graph Node, recipe=RECIPE_CONSUMER
50+
""" Create and initialize a root node from a test_package/conanfile.py consumer
51+
52+
:param lockfile: Might be good to lock python-requires, build-requires
53+
:param path: The full path to the test_package/conanfile.py being used
54+
:param tested_reference: The full RecipeReference of the tested package
55+
:param profile_host:
56+
:param profile_build:
57+
:param update:
58+
:param remotes:
59+
:return: a graph Node, recipe=RECIPE_CONSUMER
6060
"""
6161

6262
app = ConanApp(self.conan_api.cache_folder)
@@ -96,17 +96,17 @@ def load_graph(self, root_node, profile_host, profile_build, lockfile=None, remo
9696
""" Compute the dependency graph, starting from a root package, evaluation the graph with
9797
the provided configuration in profile_build, and profile_host. The resulting graph is a
9898
graph of recipes, but packages are not computed yet (package_ids) will be empty in the
99-
result.
100-
The result might have errors, like version or configuration conflicts, but it is still
99+
result. The result might have errors, like version or configuration conflicts, but it is still
101100
possible to inspect it. Only trying to install such graph will fail
102-
:param root_node: the starting point, an already initialized Node structure, as returned
103-
by the "load_root_node" api
101+
102+
:param root_node: the starting point, an already initialized Node structure, as
103+
returned by the "load_root_node" api
104104
:param profile_host: The host profile
105105
:param profile_build: The build profile
106106
:param lockfile: A valid lockfile (None by default, means no locked)
107107
:param remotes: list of remotes we want to check
108-
:param update: (False by default), if Conan should look for newer versions or revisions for
109-
already existing recipes in the Conan cache
108+
:param update: (False by default), if Conan should look for newer versions or
109+
revisions for already existing recipes in the Conan cache
110110
:param check_update: For "graph info" command, check if there are recipe updates
111111
"""
112112
app = ConanApp(self.conan_api.cache_folder)
@@ -129,12 +129,13 @@ def analyze_binaries(self, graph, build_mode=None, remotes=None, update=None, lo
129129
""" Given a dependency graph, will compute the package_ids of all recipes in the graph, and
130130
evaluate if they should be built from sources, downloaded from a remote server, of if the
131131
packages are already in the local Conan cache
132+
132133
:param lockfile:
133134
:param graph: a Conan dependency graph, as returned by "load_graph()"
134135
:param build_mode: TODO: Discuss if this should be a BuildMode object or list of arguments
135136
:param remotes: list of remotes
136-
:param update: (False by default), if Conan should look for newer versions or revisions for
137-
already existing recipes in the Conan cache
137+
:param update: (False by default), if Conan should look for newer versions or
138+
revisions for already existing recipes in the Conan cache
138139
"""
139140
conan_app = ConanApp(self.conan_api.cache_folder)
140141
conan_app.load_remotes(remotes, update=update)

conan/api/subapi/install.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def __init__(self, conan_api):
1818
@api_method
1919
def install_binaries(self, deps_graph, remotes=None, update=False):
2020
""" Install binaries for dependency graph
21-
@param deps_graph: Dependency graph to intall packages for
22-
@param remotes:
23-
@param update:
21+
:param deps_graph: Dependency graph to intall packages for
22+
:param remotes:
23+
:param update:
2424
"""
2525
app = ConanApp(self.conan_api.cache_folder)
2626
app.load_remotes(remotes, update=update)
@@ -56,7 +56,7 @@ def install_consumer(self, deps_graph, generators=None, source_folder=None, outp
5656

5757
# TODO: Look for a better location for the deployers code
5858
def _find_deployer(d, cache_deploy_folder):
59-
""" implements the logic of finding a deployer, with priority:
59+
""" Implements the logic of finding a deployer, with priority:
6060
- 1) absolute paths
6161
- 2) relative to cwd
6262
- 3) in the cache/extensions/deploy folder

conan/api/subapi/new.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def get_template(self, template_folder):
4747

4848
@api_method
4949
def get_home_template(self, template_name):
50-
""" load a template from the Conan home templates/command/new folder
50+
""" Load a template from the Conan home templates/command/new folder
5151
"""
5252
folder_template = os.path.join(self.conan_api.home_folder, "templates", "command/new",
5353
template_name)

conan/api/subapi/profiles.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ def __init__(self, conan_api):
1212

1313
def get_default_host(self):
1414
"""
15-
@return: the path to the default "host" profile, either in the cache or as defined by
16-
the user in configuration
15+
:return: the path to the default "host" profile, either in the cache or as defined
16+
by the user in configuration
1717
"""
1818
loader = ProfileLoader(self._cache)
1919
return loader.get_default_host()
2020

2121
def get_default_build(self):
2222
"""
23-
@return: the path to the default "build" profile, either in the cache or as defined by
24-
the user in configuration
23+
:return: the path to the default "build" profile, either in the cache or as
24+
defined by the user in configuration
2525
"""
2626
loader = ProfileLoader(self._cache)
2727
return loader.get_default_build()
2828

2929
def get_profile(self, profiles, settings=None, options=None, conf=None, cwd=None):
30-
""" Computes a Profile as the result of aggregating all the user arguments, first
31-
it loads the "profiles", composing them in order (last profile has priority), and finally
32-
adding the individual settings, options (priority over the profiles)
30+
""" Computes a Profile as the result of aggregating all the user arguments, first it
31+
loads the "profiles", composing them in order (last profile has priority), and
32+
finally adding the individual settings, options (priority over the profiles)
3333
"""
3434
assert profiles and isinstance(profiles, list), "Please provide at least 1 profile"
3535
loader = ProfileLoader(self._cache)
@@ -41,17 +41,17 @@ def get_profile(self, profiles, settings=None, options=None, conf=None, cwd=None
4141

4242
def get_path(self, profile, cwd=None, exists=True):
4343
"""
44-
@return: the resolved path of the given profile name, that could be in the cache, or
45-
local, depending on the "cwd"
44+
:return: the resolved path of the given profile name, that could be in the cache,
45+
or local, depending on the "cwd"
4646
"""
4747
loader = ProfileLoader(self._cache)
4848
profile_path = loader.get_profile_path(profile, cwd, exists=exists)
4949
return profile_path
5050

5151
def list(self):
5252
"""
53-
list all the profiles file sin the cache
54-
@return: an alphabetically ordered list of profile files in the default cache location
53+
List all the profiles file sin the cache
54+
:return: an alphabetically ordered list of profile files in the default cache location
5555
"""
5656
profiles = []
5757
profiles_path = self._cache.profiles_path
@@ -67,7 +67,7 @@ def list(self):
6767

6868
def detect(self):
6969
"""
70-
@return: an automatically detected Profile, with a "best guess" of the system settings
70+
:return: an automatically detected Profile, with a "best guess" of the system settings
7171
"""
7272
profile = Profile()
7373
from conans.client.conf.detect import detect_defaults_settings

conan/api/subapi/search.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ def recipe_revisions(self, expression, remote=None, none_revision_allowed=True):
8181

8282
@api_method
8383
def package_revisions(self, expression, query=None, remote=None):
84-
"""
85-
Resolve an expression like lib*/1*#*:9283*, filtering by query and obtaining all the package
86-
revisions
84+
""" Resolve an expression like lib*/1*#*:9283*, filtering by query and obtaining all the package revisions
85+
8786
:param expression: lib*/1*#*:9283*
8887
:param query: package configuration query like "os=Windows AND (arch=x86 OR compiler=gcc)"
8988
:param remote: Remote object

conan/tools/env/environment.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,13 @@ def remove(self, name, value):
192192
self._values[name].remove(value)
193193

194194
def compose_env(self, other):
195-
"""
196-
self has precedence, the "other" will add/append if possible and not conflicting, but
197-
self mandates what to do. If self has define(), without placeholder, that will remain
198-
:type other: Environment
195+
"""
196+
``self`` has precedence, the "other" will add/append if possible and not
197+
conflicting, but ``self`` mandates what to do. If ``self`` has ``define()``, without
198+
placeholder, that will remain
199+
200+
:param other: the "other" environment
201+
:type other: class:`Environment`
199202
"""
200203
for k, v in other._values.items():
201204
existing = self._values.get(k)
@@ -208,7 +211,8 @@ def compose_env(self, other):
208211

209212
def __eq__(self, other):
210213
"""
211-
:type other: Environment
214+
:param other: the "other" environment
215+
:type other: class:`Environment`
212216
"""
213217
return other._values == self._values
214218

@@ -240,7 +244,7 @@ def get(self, name, default=None):
240244
return v.get_value(self._subsystem, self._pathsep)
241245

242246
def items(self):
243-
"""returns {str: str} (varname: value)"""
247+
"""returns ``{str: str}`` (varname: value)"""
244248
return {k: v.get_value(self._subsystem, self._pathsep)
245249
for k, v in self._values.items()}.items()
246250

conan/tools/files/copy_pattern.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,26 @@
88

99
def copy(conanfile, pattern, src, dst, keep_path=True, excludes=None,
1010
ignore_case=True, copy_symlink_folders=True):
11-
"""
12-
It will copy the files matching the pattern from the src folder to the dst, including the
11+
""" It will copy the files matching the pattern from the src folder to the dst, including the
1312
symlinks to files. If a folder from "src" doesn't contain any file to be copied, it won't be
1413
created empty at the "dst".
1514
If in "src" there are symlinks to folders, they will be created at "dst" irrespective if
1615
they (or the folder where points) have files to be copied or not, unless
1716
"copy_symlink_folders=False" is specified.
1817
19-
param pattern: an fnmatch file pattern of the files that should be copied. Eg. *.dll
20-
param dst: the destination local folder, wrt to current conanfile dir, to which
21-
the files will be copied. Eg: "bin"
22-
param src: the source folder in which those files will be searched. This folder
23-
will be stripped from the dst name. Eg.: lib/Debug/x86
24-
param keep_path: False if you want the relative paths to be maintained from
25-
src to dst folders, or just drop. False is useful if you want
26-
to collect e.g. many *.libs among many dirs into a single
27-
lib dir
28-
param excludes: Single pattern or a tuple of patterns to be excluded from the copy
29-
param ignore_case: will do a case-insensitive pattern matching when True
30-
param copy_symlink_folders: Copy the symlink folders at the "dst" folder.
31-
32-
return: list of copied files
18+
:param pattern: an fnmatch file pattern of the files that should be copied. Eg. .dll
19+
:param dst: the destination local folder, wrt to current conanfile dir, to which
20+
the files will be copied. Eg: "bin"
21+
:param src: the source folder in which those files will be searched. This folder
22+
will be stripped from the dst name. Eg.: lib/Debug/x86
23+
:param keep_path: False if you want the relative paths to be maintained from src
24+
to dst folders, or just drop. False is useful if you want to collect e.g. many
25+
.libs among many dirs into a single lib dir
26+
:param excludes: Single pattern or a tuple of patterns to be excluded from the
27+
copy
28+
:param ignore_case: will do a case-insensitive pattern matching when True
29+
:param copy_symlink_folders: Copy the symlink folders at the "dst" folder.
30+
:return: list of copied files
3331
"""
3432
assert src != dst
3533
assert not pattern.startswith("..")

conan/tools/files/files.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ def _download_file(file_url):
168168

169169
def rename(conanfile, src, dst):
170170
"""
171-
rename a file or folder to avoid "Access is denied" error on Windows
171+
Rename a file or folder to avoid "Access is denied" error on Windows
172+
172173
:param conanfile: conanfile object
173174
:param src: Source file or folder
174175
:param dst: Destination file or folder
@@ -254,14 +255,14 @@ def unzip(conanfile, filename, destination=".", keep_permissions=False, pattern=
254255
strip_root=False):
255256
"""
256257
Unzip a zipped file
258+
257259
:param filename: Path to the zip file
258260
:param destination: Destination folder (or file for .gz files)
259-
:param keep_permissions: Keep the zip permissions. WARNING: Can be
260-
dangerous if the zip was not created in a NIX system, the bits could
261-
produce undefined permission schema. Use this option only if you are sure
262-
that the zip was created correctly.
263-
:param pattern: Extract only paths matching the pattern. This should be a
264-
Unix shell-style wildcard, see fnmatch documentation for more details.
261+
:param keep_permissions: Keep the zip permissions. WARNING: Can be dangerous if the
262+
zip was not created in a NIX system, the bits could produce undefined permission
263+
schema. Use this option only if you are sure that the zip was created correctly.
264+
:param pattern: Extract only paths matching the pattern. This should be a Unix
265+
shell-style wildcard, see fnmatch documentation for more details.
265266
:param flat: If all the contents are in a single dir, flat that directory.
266267
:return:
267268
"""

conan/tools/files/patches.py

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ def emit(self, record):
2626

2727

2828
def patch(conanfile, base_path=None, patch_file=None, patch_string=None, strip=0, fuzz=False, **kwargs):
29-
""" Applies a diff from file (patch_file) or string (patch_string)
30-
in base_path directory or current dir if None
29+
""" Applies a diff from file (patch_file) or string (patch_string) in base_path directory
30+
or current dir if None
31+
3132
:param base_path: Base path where the patch should be applied.
3233
:param patch_file: Patch file that should be applied.
3334
:param patch_string: Patch string that should be applied.
@@ -68,34 +69,32 @@ def patch(conanfile, base_path=None, patch_file=None, patch_string=None, strip=0
6869

6970
def apply_conandata_patches(conanfile):
7071
"""
71-
Applies patches stored in 'conanfile.conan_data' (read from 'conandata.yml' file). It will apply
72-
all the patches under 'patches' entry that matches the given 'conanfile.version'. If versions are
73-
not defined in 'conandata.yml' it will apply all the patches directly under 'patches' keyword.
74-
75-
Example of 'conandata.yml' without versions defined:
76-
77-
```
78-
patches:
79-
- patch_file: "patches/0001-buildflatbuffers-cmake.patch"
80-
base_path: "source_subfolder"
81-
- patch_file: "patches/0002-implicit-copy-constructor.patch"
82-
patch_type: backport
83-
patch_source: https://github.com/google/flatbuffers/pull/5650
84-
patch_description: Needed to build with modern clang compilers (adapted to 1.11.0 tagged sources).
85-
```
86-
87-
Example of 'conandata.yml' with different patches for different versions:
88-
```
89-
patches:
90-
"1.11.0":
72+
Applies patches stored in 'conanfile.conan_data' (read from 'conandata.yml' file). It
73+
will apply all the patches under 'patches' entry that matches the given
74+
'conanfile.version'. If versions are not defined in 'conandata.yml' it will apply all
75+
the patches directly under 'patches' keyword.
76+
77+
Example of 'conandata.yml' without versions defined::
78+
79+
patches:
9180
- patch_file: "patches/0001-buildflatbuffers-cmake.patch"
81+
base_path: "source_subfolder"
9282
- patch_file: "patches/0002-implicit-copy-constructor.patch"
93-
patch_type: backport
94-
patch_source: https://github.com/google/flatbuffers/pull/5650
95-
patch_description: Needed to build with modern clang compilers (adapted to 1.11.0 tagged sources).
96-
"1.12.0":
97-
- patch_file: "patches/0001-buildflatbuffers-cmake.patch"
98-
```
83+
patch_type: backport
84+
patch_source: https://github.com/google/flatbuffers/pull/5650
85+
patch_description: Needed to build with modern clang compilers (adapted to 1.11.0 tagged sources).
86+
87+
Example of 'conandata.yml' with different patches for different versions::
88+
89+
patches:
90+
"1.11.0":
91+
- patch_file: "patches/0001-buildflatbuffers-cmake.patch"
92+
- patch_file: "patches/0002-implicit-copy-constructor.patch"
93+
patch_type: backport
94+
patch_source: https://github.com/google/flatbuffers/pull/5650
95+
patch_description: Needed to build with modern clang compilers (adapted to 1.11.0 tagged sources).
96+
"1.12.0":
97+
- patch_file: "patches/0001-buildflatbuffers-cmake.patch"
9998
"""
10099

101100
patches = conanfile.conan_data.get('patches')

conans/server/store/disk_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ServerDiskAdapter(object):
1313
for conan operations"""
1414
def __init__(self, base_url, base_storage_path):
1515
"""
16-
:param: base_url Base url for generate urls to download and upload operations"""
16+
:param base_url Base url for generate urls to download and upload operations"""
1717

1818
self.base_url = base_url
1919
# URLs are generated removing this base path

0 commit comments

Comments
 (0)