Luke Plant avatar Luke Plant committed ee31d5d

Improved docs for writing custom replacers

Comments (0)

Files changed (1)

docs/replacers.rst

 =============================
 
 A 'replacer' is a source of faked data. The replacers in this module can be
-referred to using a string that is simply the name of the function. Custom
-replacers can be used by defining them as callables.
+referred to using a string that is simply the name of the function. They are
+listed below.
+
+Standard replacers
+==================
+
+
+.. automodule:: anonymizer.replacers
+   :members:
+
+
+Custom replacers
+================
+
+Custom replacers can be used by defining them as callables.
 
 When run by the anonymizer, the callable will be passed the Anonymizer object,
 the object being altered, the field being altered, and the current value of the
 
 All of the replacers defined in this module use a
 :class:`anonymizer.base.DjangoFaker` instance to generate fake data, and this
-object may be of use to you in writing your own replacers.
+object may be of use to you in writing your own replacers. The ``DjangoFaker``
+instance is available on the Anonymizer instance in the ``faker`` attribute. So,
+you could have a replacer callable defined like this, which uses
+:meth:`anonymizer.base.DjangoFaker.simple_pattern`::
 
-
-.. automodule:: anonymizer.replacers
-   :members:
+    lambda anon, obj, field, val: anon.faker.simple_pattern('???##', field=field)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.