Skip to content

Commit 7bc3f3e

Browse files
committed
docs: Port to numpy-style format
1 parent 5bef968 commit 7bc3f3e

File tree

5 files changed

+132
-81
lines changed

5 files changed

+132
-81
lines changed

vcspull/cli.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
def setup_logger(log=None, level='INFO'):
3434
"""Setup logging for CLI use.
3535
36-
:param log: instance of logger
37-
:type log: :py:class:`Logger`
38-
36+
Parameters
37+
----------
38+
log : :py:class:`Logger`
39+
instance of logger
3940
"""
4041
if not log:
4142
log = logging.getLogger()

vcspull/cli_defaultgroup.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ def bar():
4343

4444

4545
class DefaultGroup(click.Group):
46-
"""Invokes a subcommand marked with `default=True` if any subcommand not
47-
chosen.
48-
:param default_if_no_args: resolves to the default command if no arguments
49-
passed.
46+
"""Invokes a subcommand marked with `default=True` if any subcommand not chosen.
47+
48+
Parameters
49+
----------
50+
default_if_no_args :
51+
resolves to the default command if no arguments passed.
5052
"""
5153

5254
def __init__(self, *args, **kwargs):

vcspull/config.py

+100-58
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@
2626
def expand_dir(_dir, cwd=os.getcwd()):
2727
"""Return path with environmental variables and tilde ~ expanded.
2828
29-
:param _dir:
30-
:type _dir: str
31-
:param cwd: current working dir (for deciphering relative _dir paths)
32-
:type cwd: str
33-
:rtype; str
29+
Parameters
30+
----------
31+
_dir : str
32+
cwd : str, optional
33+
current working dir (for deciphering relative _dir paths), defaults to
34+
:py:meth:`os.getcwd()`
35+
36+
Returns
37+
-------
38+
str :
39+
Absolute directory path
3440
"""
3541
_dir = os.path.expanduser(os.path.expandvars(_dir))
3642
if not os.path.isabs(_dir):
@@ -44,12 +50,16 @@ def extract_repos(config, cwd=os.getcwd()):
4450
end-user configuration permit inline configuration shortcuts, expand to
4551
identical format for parsing.
4652
47-
:param config: the repo config in :py:class:`dict` format.
48-
:type config: dict
49-
:param cwd: current working dir (for deciphering relative paths)
50-
:type cwd: str
51-
:rtype: list
53+
Parameters
54+
----------
55+
config : dict
56+
the repo config in :py:class:`dict` format.
57+
cwd : str
58+
current working dir (for deciphering relative paths)
5259
60+
Returns
61+
-------
62+
list : List of normalized repository information
5363
"""
5464
configs = []
5565
for directory, repos in config.items():
@@ -137,20 +147,26 @@ def find_config_files(
137147
):
138148
"""Return repos from a directory and match. Not recursive.
139149
140-
:param path: list of paths to search
141-
:type path: list
142-
:param match: list of globs to search against
143-
:type match: list
144-
:param filetype: list of filetypes to search against
145-
:type filetype: list
146-
:param include_home: Include home configuration files
147-
:type include_home: bool
148-
:raises:
149-
- LoadConfigRepoConflict: There are two configs that have same path
150-
and name with different repo urls.
151-
:returns: list of absolute paths to config files.
152-
:rtype: list
153-
150+
Parameters
151+
----------
152+
path : list
153+
list of paths to search
154+
match : list
155+
list of globs to search against
156+
filetype: list
157+
of filetypes to search against
158+
include_home : bool
159+
Include home configuration files
160+
161+
Raises
162+
------
163+
LoadConfigRepoConflict :
164+
There are two configs that have same path and name with different repo urls.
165+
166+
Returns
167+
-------
168+
list :
169+
list of absolute paths to config files.
154170
"""
155171
configs = []
156172

@@ -182,14 +198,21 @@ def find_config_files(
182198
def load_configs(files, cwd=os.getcwd()):
183199
"""Return repos from a list of files.
184200
185-
:todo: Validate scheme, check for duplciate destinations, VCS urls
186-
187-
:param files: paths to config file
188-
:type files: list
189-
:param cwd: current path (pass down for :func:`extract_repos`
190-
:type cwd: str
191-
:returns: expanded config dict item
192-
:rtype: list of dict
201+
Parameters
202+
----------
203+
files : list
204+
paths to config file
205+
cwd : str
206+
current path (pass down for :func:`extract_repos`
207+
208+
Returns
209+
-------
210+
list of dict :
211+
expanded config dict item
212+
213+
Todo
214+
----
215+
Validate scheme, check for duplciate destinations, VCS urls
193216
"""
194217
repos = []
195218
for f in files:
@@ -215,12 +238,18 @@ def load_configs(files, cwd=os.getcwd()):
215238
def detect_duplicate_repos(repos1, repos2):
216239
"""Return duplicate repos dict if repo_dir same and vcs different.
217240
218-
:param repos1: list of repo expanded dicts
219-
:type repos1: list of :py:dict
220-
:param repos2: list of repo expanded dicts
221-
:type repos2: list of :py:dict
222-
:rtype: list of dicts or None
223-
:returns: Duplicate lists
241+
Parameters
242+
----------
243+
repos1 : dict
244+
list of repo expanded dicts
245+
246+
repos2 : dict
247+
list of repo expanded dicts
248+
249+
Returns
250+
-------
251+
list of dict, or None
252+
Duplicate repos
224253
"""
225254
dupes = []
226255
path_dupe_repos = []
@@ -249,12 +278,16 @@ def detect_duplicate_repos(repos1, repos2):
249278
def in_dir(config_dir=CONFIG_DIR, extensions=['.yml', '.yaml', '.json']):
250279
"""Return a list of configs in ``config_dir``.
251280
252-
:param config_dir: directory to search
253-
:type config_dir: str
254-
:param extensions: filetypes to check (e.g. ``['.yaml', '.json']``).
255-
:type extensions: list
256-
:rtype: list
281+
Parameters
282+
----------
283+
config_dir : str
284+
directory to search
285+
extensions : list
286+
filetypes to check (e.g. ``['.yaml', '.json']``).
257287
288+
Returns
289+
-------
290+
list
258291
"""
259292
configs = []
260293

@@ -270,16 +303,21 @@ def filter_repos(config, repo_dir=None, vcs_url=None, name=None):
270303
271304
repo_dir, vcs_url and name all support fnmatch.
272305
273-
:param config: the expanded repo config in :py:class:`dict` format.
274-
:type config: dict
275-
:param repo_dir: directory of checkout location, fnmatch pattern supported
276-
:type repo_dir: str or None
277-
:param vcs_url: url of vcs remote, fn match pattern supported
278-
:type vcs_url: str or None
279-
:param name: project name, fnmatch pattern supported
280-
:type name: str or None
281-
:rtype: list
282-
306+
Parameters
307+
----------
308+
config : dist
309+
the expanded repo config in :py:class:`dict` format.
310+
repo_dir : str, Optional
311+
directory of checkout location, fnmatch pattern supported
312+
vcs_url : str, Optional
313+
url of vcs remote, fn match pattern supported
314+
name : str, Optional
315+
project name, fnmatch pattern supported
316+
317+
Returns
318+
-------
319+
list :
320+
Repos
283321
"""
284322
repo_list = []
285323

@@ -302,12 +340,16 @@ def filter_repos(config, repo_dir=None, vcs_url=None, name=None):
302340
def is_config_file(filename, extensions=['.yml', '.yaml', '.json']):
303341
"""Return True if file has a valid config file type.
304342
305-
:param filename: filename to check (e.g. ``mysession.json``).
306-
:type filename: str
307-
:param extensions: filetypes to check (e.g. ``['.yaml', '.json']``).
308-
:type extensions: list or str
309-
:rtype: bool
343+
Parameters
344+
----------
345+
filename : str
346+
filename to check (e.g. ``mysession.json``).
347+
extensions : list or str
348+
filetypes to check (e.g. ``['.yaml', '.json']``).
310349
350+
Returns
351+
-------
352+
bool : True if is a valid config file type
311353
"""
312354
extensions = [extensions] if isinstance(extensions, string_types) else extensions
313355
return any(filename.endswith(e) for e in extensions)

vcspull/log.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
def default_log_template(self, record):
3131
"""Return the prefix for the log message. Template for Formatter.
3232
33-
:param: record: :py:class:`logging.LogRecord` object. this is passed in
34-
from inside the :py:meth:`logging.Formatter.format` record.
35-
33+
Parameters
34+
----------
35+
record : :py:class:`logging.LogRecord`
36+
This is passed in from inside the :py:meth:`logging.Formatter.format` record.
3637
"""
37-
3838
reset = [Style.RESET_ALL]
3939
levelname = [
4040
LEVEL_COLORS.get(record.levelname),
@@ -92,11 +92,12 @@ def format(self, record):
9292

9393

9494
def debug_log_template(self, record):
95-
""" Return the prefix for the log message. Template for Formatter.
96-
97-
:param: record: :class:`logging.LogRecord` object. this is passed in
98-
from inside the :py:meth:`logging.Formatter.format` record.
95+
"""Return the prefix for the log message. Template for Formatter.
9996
97+
Parameters
98+
----------
99+
record : :class:`logging.LogRecord`
100+
This is passed in from inside the :py:meth:`logging.Formatter.format` record.
100101
"""
101102

102103
reset = [Style.RESET_ALL]

vcspull/util.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@
2222
def update_dict(d, u):
2323
"""Return updated dict.
2424
25-
http://stackoverflow.com/a/3233356
26-
27-
:param d: dict
28-
:type d: dict
29-
:param u: updated dict.
30-
:type u: dict
31-
:rtype: dict
32-
25+
Parameters
26+
----------
27+
d : dict
28+
u : dict
29+
30+
Returns
31+
-------
32+
dict :
33+
Updated dictionary
34+
35+
Notes
36+
-----
37+
Thanks: http://stackoverflow.com/a/3233356
3338
"""
3439
for k, v in u.items():
3540
if isinstance(v, Mapping):

0 commit comments

Comments
 (0)