src/pretty: add usage example in DocUnit
[nit.git] / src / pretty.nit
index 3b3cb90..75d9879 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# Library used to pretty print Nit code.
+#
+# Usage:
+#
+#     import parser_util
+#     var tc = new ToolContext
+#     var nmodule = tc.parse_something("class A\nfun   toto :  Int  do   return   5\nend")
+#     var ppv = new PrettyPrinterVisitor
+#     var pmodule = ppv.pretty(nmodule)
+#     assert pmodule.write_to_string == """
+#     class A
+#     \tfun toto: Int do return 5
+#     end"""
+#
+# See `nitpretty` tool for more documentation.
 module pretty
 
 import template
@@ -221,6 +236,7 @@ class PrettyPrinterVisitor
        # Add a space.
        fun adds do add " "
 
+       # Visit explicit receiver, implicit self will be ignored.
        fun visit_recv(n_expr: AExpr) do
                if not n_expr isa AImplicitSelfExpr then
                        visit n_expr