Skip to content

Commit

Permalink
[docs] fix class/__init__ docs so sphinx builds them properly
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrowla committed Apr 9, 2019
1 parent 386200d commit 5c1ea27
Show file tree
Hide file tree
Showing 7 changed files with 475 additions and 442 deletions.
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,7 @@
'One line description of project.',
'Miscellaneous'),
]

# -- autodoc options

autodoc_member_order = 'bysource'
44 changes: 20 additions & 24 deletions livemaker/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,27 @@ class LMArchive(object):
Behaves in the same manner as Python ``tarfile.TarFile`` or ``zipfile.ZipFile``.
Can be used inside a Python ``with`` statement (in the same way as zip/tar files).
Args:
name: Pathname for the archive. `name` can be a string or path-like object.
If omitted, `fp` must be specified.
mode: Either ``'r'`` to read from an existing archive or ``'w'`` to create a new file
(overwriting an existing one). Defaults to ``'r'``.
fp: If `fileobj` is given, it will be used for reading and writing data.
If it can be determined, `mode` will be overridden by `fp`'s mode. `fileobj`
will be used from position 0.
exe: Pathname for LiveMaker executable (``.exe``) file. If `exe` is given and
`mode` is ``w``, the output file will be an executable with the archive
appended to the end (i.e. a LiveMaker ``.exe`` file). If `exe` is not given,
the output file will be a standalone archive (i.e. a LiveMaker ``.dat`` file).
`exe` does nothing when opening a file for reading.
version: Archive version, only applies to write mode.
Note:
`fp` is not closed when `LiveMakerArchive` is closed.
``'a'`` is an invalid `mode` for `LiveMakerArchive`. Archives cannot be modified
in place, to patch an existing archive, you must write to a new file.
When opened in write mode, the output archive file will not be written until
`LMArchive.close()` is called. As entries are added to the archive, they will
be written to a temporary file. Upon calling `close()`, the exe (if it exists)
Expand All @@ -379,30 +399,6 @@ class LMArchive(object):
"""

def __init__(self, name=None, mode='r', fp=None, exe=None, version=DEFAULT_VERSION):
"""Open LiveMaker archive `name` for reading or writing.
Args:
name: Pathname for the archive. `name` can be a string or path-like object.
If omitted, `fp` must be specified.
mode: Either ``'r'`` to read from an existing archive or ``'w'`` to create a new file
(overwriting an existing one). Defaults to ``'r'``.
fp: If `fileobj` is given, it will be used for reading and writing data.
If it can be determined, `mode` will be overridden by `fp`'s mode. `fileobj`
will be used from position 0.
exe: Pathname for LiveMaker executable (``.exe``) file. If `exe` is given and
`mode` is ``w``, the output file will be an executable with the archive
appended to the end (i.e. a LiveMaker ``.exe`` file). If `exe` is not given,
the output file will be a standalone archive (i.e. a LiveMaker ``.dat`` file).
`exe` does nothing when opening a file for reading.
version: Archive version, only applies to write mode.
Note:
`fp` is not closed when `LiveMakerArchive` is closed.
``'a'`` is an invalid `mode` for `LiveMakerArchive`. Archives cannot be modified
in place, to patch an existing archive, you must write to a new file.
"""
self.closed = True
if not name and fp:
raise ValueError('Nothing to open')
Expand Down
19 changes: 15 additions & 4 deletions livemaker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def validate(input_file):


@lmlsb.command()
@click.option('-m', '--mode', type=click.Choice(['text', 'xml']), default='text',
@click.option('-m', '--mode', type=click.Choice(['text', 'xml', 'lines']), default='text',
help='Output mode (defaults to text)')
@click.option('-e', '--encoding', type=click.Choice(['cp932', 'utf-8']), default='utf-8',
help='Output text encoding (defaults to utf-8).')
Expand All @@ -227,10 +227,9 @@ def dump(mode, encoding, input_file):
For text mode, the full LSB will be output as human-readable text.
For script mode, only decompiled script content will be output (i.e. the TpWord content
in any TComTextIns text commands).
For xml mode, the full LSB file will be output as an XML document.
For lines mode, only text lines will be output.
"""
for path in input_file:
with open(path, 'rb') as f:
Expand All @@ -243,6 +242,18 @@ def dump(mode, encoding, input_file):
if mode == 'xml':
root = lsb.to_xml()
print(etree.tostring(root, encoding=encoding, pretty_print=True, xml_declaration=True).decode(encoding))
elif mode == 'lines':
lsb_path = Path(path)
for line, name, scenario in lsb.text_scenarios():
if name:
name = '{}-{}.lns'.format(lsb_path.stem, name)
if not name:
name = '{}-line{}.lns'.format(lsb_path.stem, line)
print(name)
print('------')
dec = LNSDecompiler(text_only=True)
print(dec.decompile(scenario))
print()
else:
for c in lsb.commands:
if c.Mute:
Expand Down
Loading

0 comments on commit 5c1ea27

Please sign in to comment.