Skip to content

Commit

Permalink
Rewrite docstrings in Google style, fix #67 (#88)
Browse files Browse the repository at this point in the history
* Transcribe docstrings in `fs.filesize`

* Start rewriting docstrings to Google style

* Add pydocstyle configuration to `setup.cfg`

* Enforce Google conventions in param types

* Edit most docstrings of `fs` submodules

* Enhance docstrings of properties

* Transcribe docstrings in `fs.osfs`

* Transcribe docstrings in `fs.zipfs`

* changed ValueError to TypeError

* Minor fixes to documentation

* Configure pydocstyle to ignore tests folder

* Rewrite errors docstring in stdlib-style

* Add subsection titles to the doc source

* Make pydocstyle ignore private modules

* Fix all non-D102 pydocstyle errors

* Remove '# noqa: D102' and ignore it in config file.

* Add `fs.filesize` to doc reference

* Move some documentation in the source doc to the source code

* Add docstring title to every public module.

* Fix miscellaneous documentation issues.

* Use default ':obj:' ref inside docstrings

* Fix non-ASCII symbol breaking build on Python 2.7

* Fix missing double quotes in `BoundWalker.info`
  • Loading branch information
althonos authored and willmcgugan committed Oct 11, 2017
1 parent d2da568 commit a23e87f
Show file tree
Hide file tree
Showing 71 changed files with 2,386 additions and 2,050 deletions.
11 changes: 9 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode'
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'sphinx.ext.intersphinx'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# intersphinx domain mapping
intersphinx_mapping = {
'python': ('https://docs.python.org/3.6', None)
}

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
Expand Down Expand Up @@ -89,7 +96,7 @@

# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
default_role = 'py:obj'

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
Expand Down
1 change: 1 addition & 0 deletions docs/source/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Reference
reference/enums.rst
reference/errors.rst
reference/info_objects.rst
reference/filesize.rst
reference/mirror.rst
reference/move.rst
reference/mode.rst
Expand Down
4 changes: 1 addition & 3 deletions docs/source/reference/appfs.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
App Filesystems
===============

Filesystems for platform-specific application directories.

.. automodule:: fs.appfs
:members:
:members:
12 changes: 4 additions & 8 deletions docs/source/reference/base.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
fs.base.FS
==========
fs.base
=======

The filesystem base class is common to all filesystems. If you
familiarize yourself with this (rather straightforward) API, you can
work with any of the supported filesystems.

.. autoclass:: fs.base.FS
:members:
.. automodule:: fs.base
:members: FS
4 changes: 1 addition & 3 deletions docs/source/reference/copy.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
fs.copy
=======

Copying files from one filesystem to another.

.. automodule:: fs.copy
:members:
:members:
9 changes: 3 additions & 6 deletions docs/source/reference/enums.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
fs.enums
========

.. autoclass:: fs.ResourceType
:members:


.. autoclass:: fs.Seek
:members:
.. automodule:: fs.enums
:members: ResourceType, Seek
:member-order: bysource
3 changes: 2 additions & 1 deletion docs/source/reference/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ fs.errors
=========

.. automodule:: fs.errors
:members:
:members:
:show-inheritance:
5 changes: 5 additions & 0 deletions docs/source/reference/filesize.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fs.filesize
===========

.. automodule:: fs.filesize
:members:
4 changes: 1 addition & 3 deletions docs/source/reference/ftpfs.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FTP Filesystem
==============

Manage resources on a FTP server.

.. automodule:: fs.ftpfs
:members:
:members:
4 changes: 1 addition & 3 deletions docs/source/reference/memoryfs.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Memory Filesystem
=================

Create and manage an in-memory filesystems.

.. automodule:: fs.memoryfs
:members:
:members:
19 changes: 2 additions & 17 deletions docs/source/reference/mirror.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
fs.mirror
=========

Create a duplicate of a filesystem.

Mirroring will create a copy of a source filesystem on a destination
filesystem. If there are no files on the destination, then mirroring
is simply a straight copy. If there are any files or directories on the
destination they may be deleted or modified to match the source.

In order to avoid redundant copying of files, ``mirror`` can compare
timestamps, and only copy files with a newer modified date. This
timestamp comparison is only done if the file sizes are different.

This scheme will work if you have mirrored a directory previously, and
you would like to copy any changes. Otherwise you should set the
``copy_if_newer`` parameter to ``False`` to guarantee an exact copy, at
the expense of potentially copying extra files.

.. autofunction:: fs.mirror.mirror
.. automodule:: fs.mirror
:members: mirror
7 changes: 5 additions & 2 deletions docs/source/reference/mountfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@ Now both filesystems may be accessed with the same path structure::
print(combined_fs.gettext('/config/defaults.cfg'))
read_jpg(combined_fs.open('/resources/images/logo.jpg', 'rb')

.. automodule:: fs.mountfs
:members:
.. autoclass:: fs.mountfs.MountFS
:members:

.. autoexception:: fs.mountfs.MountError
:show-inheritance:
4 changes: 1 addition & 3 deletions docs/source/reference/move.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
fs.move
=======

Moving files from one filesystem to another.

.. automodule:: fs.move
:members:
:members:
4 changes: 2 additions & 2 deletions docs/source/reference/multifs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ directories::
`-- theme.html


.. automodule:: fs.multifs
:members:
.. autoclass:: fs.multifs.MultiFS
:members:
9 changes: 9 additions & 0 deletions docs/source/reference/opener.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@ fs.opener

Open filesystems from a URL.

fs.opener.base
--------------
.. automodule:: fs.opener.base
:members:

fs.opener.parse
---------------
.. automodule:: fs.opener.parse
:members:

fs.opener.registry
------------------
.. automodule:: fs.opener.registry
:members:

fs.opener.errors
----------------
.. automodule:: fs.opener.errors
:members:
:show-inheritance:
4 changes: 0 additions & 4 deletions docs/source/reference/osfs.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
OS Filesystem
=============

Manage the filesystem provided by your OS.

In essence an ``OSFS`` is a thin layer over the ``io`` and ``os`` modules in the Python library.

.. automodule:: fs.osfs
:members:
3 changes: 2 additions & 1 deletion docs/source/reference/subfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Sub Filesystem
==============

.. automodule:: fs.subfs
:members:
:members:
:member-order: bysource
3 changes: 1 addition & 2 deletions docs/source/reference/tarfs.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Tar Filesystem
==============

A filesystem implementation for .tar files.

.. automodule:: fs.tarfs
:members:
:member-order: bysource
6 changes: 1 addition & 5 deletions docs/source/reference/tempfs.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
Temporary Filesystem
====================

A temporary filesytem is stored in a location defined by your OS (``/tmp`` on linux). The contents are deleted when the filesystem is closed.

A ``TempFS`` is a good way of preparing a directory structure in advance, that you can later copy. It can also be used as a temporary data store.

.. automodule:: fs.tempfs
:members:
:members:
4 changes: 1 addition & 3 deletions docs/source/reference/tree.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
fs.tree
=======

Render a text tree view, with optional color in terminals.

.. automodule:: fs.tree
:members:
:members:
3 changes: 1 addition & 2 deletions docs/source/reference/zipfs.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Zip Filesystem
==============

A filesystem implementation for .zip files.

.. automodule:: fs.zipfs
:members:
:member-order: bysource
3 changes: 3 additions & 0 deletions fs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""Python filesystem abstraction layer.
"""

__import__('pkg_resources').declare_namespace(__name__)

from ._version import __version__
Expand Down
24 changes: 12 additions & 12 deletions fs/_repr.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
"""
Tools to generate __repr__ strings
"""Tools to generate __repr__ strings.
"""

from __future__ import unicode_literals

def make_repr(class_name, *args, **kwargs):
"""
Generate a repr string.
"""Generate a repr string.
Positional arguments should be the positional arguments used to
construct the class. Keyword arguments should consist of tuples of
the attribute value and default. If the value is the default, then
it won't be rendered in the output.
Here's an example::
def __repr__(self):
return make_repr('MyClass', 'foo', name=(self.name, None))
The output of this would be something line ``MyClass('foo',
name='Will')``.
Example:
>>> class MyClass(object):
... def __init__(self, name=None):
... self.name = name
... def __repr__(self):
... return make_repr('MyClass', 'foo', name=(self.name, None))
>>> MyClass('Will')
MyClass('foo', name='Will')
>>> MyClass(None)
MyClass()
"""
arguments = [repr(arg) for arg in args]
Expand Down
3 changes: 2 additions & 1 deletion fs/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Version, used in module and setup.py."""
"""Version, used in module and setup.py.
"""
__version__ = "2.0.12a0"
Loading

0 comments on commit a23e87f

Please sign in to comment.