feat: Make the start
parameter to a semiliterate pattern optional
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Resolves #4.
This commit is contained in:
parent
2235af160c
commit
981384c6f7
@ -12,7 +12,6 @@ plugins:
|
||||
include_extensions: [LICENSE]
|
||||
semiliterate:
|
||||
- pattern: '(\.md)$'
|
||||
start: '^(.*\s*)'
|
||||
replace: [['^(.*)<!-- repo: -->.*<!-- site:(.*?) -->(.*\s*)$', '\1\2\3']]
|
||||
- pattern: '(\.py)$'
|
||||
start: '"""\smd'
|
||||
|
@ -49,6 +49,30 @@ it's the text **after** the application of any semiliterate `replace`ments that
|
||||
is checked for `{! ... !}`.
|
||||
"""
|
||||
|
||||
def __init__(self, input_stream, output_stream, **kwargs):
|
||||
""" md
|
||||
### Adjusted semiliterate options
|
||||
|
||||
The `start` regular-expression parameter to a `semiliterate` file-inclusion
|
||||
pattern is now optional. If omitted, it means that extraction begins immediately
|
||||
with the first line of a file; in this case, `pause` and `terminate` retain
|
||||
their usual meanings, although there is not currently any way to resume from a
|
||||
`pause` when `start` is not specified. This adjustment to `semiliterate`
|
||||
parameters makes it easier to extract "front-matter" style documentation from
|
||||
files.
|
||||
"""
|
||||
self.start_hot = False
|
||||
if 'start' not in kwargs:
|
||||
kwargs['start'] = 'dummy'
|
||||
self.start_hot = True
|
||||
super().__init__(input_stream, output_stream, **kwargs)
|
||||
|
||||
def extract(self):
|
||||
if self.start_hot:
|
||||
self.extracting = True
|
||||
self.start = False
|
||||
super().extract()
|
||||
|
||||
include_open = re.compile(r'''(?<![`\\])(\{\!\s*)([\s'"])''')
|
||||
include_quoted_file = re.compile(
|
||||
r'''(['"])(?P<fn>.*?)\1\s+(?P<yml>[\s\S]*?)\s\!\}''')
|
||||
|
Loading…
Reference in New Issue
Block a user