Clarify file.line state docs as well

This commit is contained in:
rallytime 2016-11-04 10:04:37 -06:00
parent b2615892eb
commit 8b2d2b9e7b

View file

@ -2653,43 +2653,57 @@ def line(name, content, match=None, mode=None, location=None,
.. versionadded:: 2015.8.0
:param name:
name
Filesystem path to the file to be edited.
:param content:
content
Content of the line.
:param match:
match
Match the target line for an action by
a fragment of a string or regular expression.
:param mode:
:Ensure:
If neither ``before`` nor ``after`` are provided, and ``match``
is also ``None``, match becomes the ``content`` value.
mode
Defines how to edit a line. One of the following options is
required:
- ensure
If line does not exist, it will be added.
:Replace:
If line already exist, it will be replaced.
:Delete:
- replace
If line already exists, it will be replaced.
- delete
Delete the line, once found.
:Insert:
- insert
Insert a line.
:param location:
:start:
Place the content at the beginning of the file.
.. note::
:end:
If ``mode=insert`` is used, at least one of the following
options must also be defined: ``location``, ``before``, or
``after``. If ``location`` is used, it takes precedence
over the other two options.
location
Defines where to place content in the line. Note this option is only
used when ``mode=insert`` is specified. If a location is passed in, it
takes precedence over both the ``before`` and ``after`` kwargs. Valid
locations are:
- start
Place the content at the beginning of the file.
- end
Place the content at the end of the file.
:param before:
before
Regular expression or an exact case-sensitive fragment of the string.
:param after:
after
Regular expression or an exact case-sensitive fragment of the string.
:param show_changes:
show_changes
Output a unified diff of the old file and the new file.
If ``False`` return a boolean if any changes were made.
Default is ``True``
@ -2698,15 +2712,15 @@ def line(name, content, match=None, mode=None, location=None,
Using this option will store two copies of the file in-memory
(the original version and the edited version) in order to generate the diff.
:param backup:
backup
Create a backup of the original file with the extension:
"Year-Month-Day-Hour-Minutes-Seconds".
:param quiet:
quiet
Do not raise any exceptions. E.g. ignore the fact that the file that is
tried to be edited does not exist and nothing really happened.
:param indent:
indent
Keep indentation with the previous line.
.. code-block: yaml