You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 22, 2021. It is now read-only.
Fixes from final CR
Update to pyparsing 2.1.8
Adds build target
Adds build target
Moves testing utilities
Increments version
Minor Makefile change
Fixes some issues that arose when writing patterns
Version bump
Copy file name to clipboardExpand all lines: README.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# Undebt
2
2
3
-
Undebt is a fast, simple, reliable tool for performing massive, automated code refactoring used [@Yelp](https://github.com/Yelp). Undebt lets you define complex find-and-replace rules using simple, straightforward Python that can be applied quickly to an entire code base with a simple command.
3
+
Undebt is a fast, straightforward, reliable tool for performing massive, automated code refactoring used [@Yelp](https://github.com/Yelp). Undebt lets you define complex find-and-replace rules using standard, straightforward Python that can be applied quickly to an entire code base with a simple command.
4
+
5
+
To learn about what Undebt is and why we created it, check out our [post on the Yelp Engineering Blog](http://engineeringblog.yelp.com/).
Copy file name to clipboardExpand all lines: docs/source/patterns.rst
+5-5
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,9 @@ Undebt_: Pattern Files
7
7
Undebt requires a pattern file that describes what to replace and how to replace it. There are two different ways to write pattern files: basic style, and advanced style. Unless you know you need multi-pass parsing, you should use basic style by default.
8
8
9
9
Basic Style
10
-
---------------
10
+
-----------
11
11
12
-
When writing an basic style pattern, you must define the following names in your pattern file:
12
+
If you don't know what style you should be using, you should be using basic style. When writing a basic style pattern, you must define the following names in your pattern file:
13
13
14
14
- `grammar` defines what pattern you want to replace, and must be a pyparsing_ grammar object.
15
15
- `replace` is a function of one argument, the tokens produced by `grammar`, that returns the string they should be replaced with, or `None` to do nothing (this is the single-argument form—multi-argument is also allowed as documented `below`_).
@@ -24,9 +24,9 @@ That sounds complicated, but it's actually very simple. To start learning more,
24
24
.. _`pattern utilities`: util.html
25
25
26
26
Advanced Style
27
-
------------------
27
+
--------------
28
28
29
-
When writing an advanced style pattern, you need only define one name:
29
+
Unlike basic style, advanced style allows you to use custom multi-pass parsing—if that's not something you need, you should use basic style. When writing an advanced style pattern, you need only define one name:
30
30
31
31
- `patterns` is a list of `(grammar, replace)` tuples, where each tuple in the list is only run if the previous one succeeded
32
32
@@ -58,4 +58,4 @@ Or equivalently but more succinctly::
58
58
Multi-Argument Replace
59
59
----------------------
60
60
61
-
In both styles, when writing a `replace` function, it is sometimes useful to have access to the location in and/or text of the original file. If your `replace` function takes two arguments, it will be passed `location, tokens`, and for three arguments, it will get `text, location, tokens`. This will work even if you are using one of the `tokens_as_list` or `tokens_as_dict` decorator.
61
+
In both styles, when writing a `replace` function, it is sometimes useful to have access to the parsing location in the file and/or the text of the original file. If your `replace` function takes two arguments, it will be passed `location, tokens`, and for three arguments, it will get `text, location, tokens`. This will work even if you are using one of the `tokens_as_list` or `tokens_as_dict` decorators.
Copy file name to clipboardExpand all lines: docs/source/util.rst
+8-4
Original file line number
Diff line number
Diff line change
@@ -41,9 +41,13 @@ Returns the whitespace at the end of `text`.
41
41
42
42
Modifies a grammar element to always parse to the same fixed `output`.
43
43
44
+
**debug(item)**
45
+
46
+
Modifies a grammar element to print the tokens that it matches.
47
+
44
48
**attach(item, action)**
45
49
46
-
Modifies a grammar element to parse to the result of calling `action` on the tokens produced by that grammar element. Used to implement `condense`, `addspace`, and `fixto`.
50
+
Modifies a grammar element to parse to the result of calling `action` on the tokens produced by that grammar element.
47
51
48
52
`undebt.pattern.common`
49
53
-----------------------
@@ -90,12 +94,12 @@ Grammar elements that match different types of multi-line strings.
90
94
**COMMA_IND, LPAREN_IND, IND_RPAREN**
91
95
Same as `COMMA`, `LPAREN`, and `RPAREN`, but allow for an `INDENT` after (for `COMMA_IND` and `LPAREN_IND`) or before (for `IND_RPAREN`).
92
96
93
-
**NO_BS_NL**
94
-
Matches a new line not preceded by a backslash.
95
-
96
97
**LINE_START**
97
98
Matches the start of a line, either after a new line, or at the start of the file.
98
99
100
+
**NO_BS_NL**
101
+
Matches a new line not preceded by a backslash.
102
+
99
103
**START_OF_FILE**
100
104
Grammar element that only matches at the very beginning of the file.
0 commit comments