Skip to content

Commit f09298e

Browse files
archived-ckzsnow
andauthored
Update docstring for Zelos class, add docs for available flags (#8)
* Update docstring for Zelos class, add documentation for all available flags. * Add image to README * Update README, docs/conf.py Co-authored-by: Zeropoint <[email protected]>
1 parent 93ced98 commit f09298e

File tree

8 files changed

+51
-6
lines changed

8 files changed

+51
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
88

99
# Zelos
10-
Zelos is a Python-based binary emulation platform. Linux x86, x86_64, ARMv7 and MIPS binaries are supported.
10+
Zelos (**Z**eropoint **E**mulated **L**ightweight **O**perating **S**ystem) is a python-based binary emulation platform. One use of zelos is to quickly assess the dynamic behavior of binaries via command-line or python scripts. All syscalls are emulated to isolate the target binary. Linux x86_64 (32- and 64-bit), ARM and MIPS binaries are supported.
1111

12-
## Documentation
12+
![Image](/docs/_static/hello_zelos.png)
1313

14-
All of the documentation can be found on [readthedocs](https://zelos.readthedocs.io/en/latest/index.html)
14+
[Full documentation](https://zelos.readthedocs.io/en/latest/index.html) is available [here](https://zelos.readthedocs.io/en/latest/index.html).
1515

1616
## Installation
1717

docs/_static/hello_zelos.png

85.9 KB
Loading

docs/args/args.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. _flag-label:
2+
3+
Flags
4+
=================
5+
6+
Available Flags & Usage
7+
-----------------------
8+
9+
.. argparse::
10+
:ref: zelos.config_gen.generate_parser
11+
:prog: zelos

docs/conf.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# add these directories to sys.path here. If the directory is relative to the
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
#
13+
14+
import fileinput
1315
import os
1416
import shutil
1517
import sys
@@ -26,7 +28,11 @@
2628

2729

2830
shutil.copyfile(os.path.join("..", "README.md"), "README.md")
29-
31+
for line in fileinput.input("README.md", inplace=True):
32+
if "![Image](/docs/_static/hello_zelos.png)" in line:
33+
print("![Image](_static/hello_zelos.png)")
34+
else:
35+
print(line, end="")
3036

3137
# -- Project information -----------------------------------------------------
3238

@@ -51,6 +57,7 @@
5157
"sphinx.ext.doctest",
5258
"sphinx.ext.todo",
5359
"sphinx.ext.intersphinx",
60+
"sphinxarg.ext",
5461
]
5562

5663
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Zelos Documentation
2323
:maxdepth: 1
2424

2525
api/zelos.api
26+
args/args
2627

2728
.. toctree::
2829
:caption: Internal Package Docs

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"sphinx_rtd_theme",
5757
"sphinxcontrib-apidoc",
5858
"recommonmark",
59+
"sphinx-argparse",
5960
],
6061
"tests": [
6162
"coverage",

src/zelos/api/zelos_api.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,29 @@
3131

3232
class Zelos:
3333
"""
34-
Class that provides access to core api wrappers. These core APIs
34+
Class that provides access to the core APIs. These core APIs
3535
are event hooking, debugging, memory access, register access, and
3636
emulation context.
37+
38+
Args:
39+
filename: Specifies the name of the file to emulate.
40+
cmdline_args: Arguments that are passed to the emulated binary.
41+
flags: Parameters for zelos. To see the list of all flags, refer
42+
to :ref:`flag-label`
43+
44+
Example:
45+
.. code-block:: python
46+
47+
from zelos import Zelos
48+
49+
# initialize zelos with binary name, 2 cmdline args, and
50+
# verbosity flag set to 1
51+
z = Zelos(
52+
"binary_to_emulate"
53+
"ARG1",
54+
"ARG2",
55+
verbosity=1,
56+
)
3757
"""
3858

3959
def __init__(self, filename, *cmdline_args, **flags):

src/zelos/config_gen.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _generate_without_binary(**kwargs):
6969
return config
7070

7171

72-
def generate_config_from_cmdline(cmdline_string):
72+
def generate_parser():
7373
parser = configargparse.ArgumentParser()
7474
group_logging = parser.add_argument_group("logging")
7575
group_reporting = parser.add_argument_group("reporting")
@@ -220,6 +220,11 @@ def generate_config_from_cmdline(cmdline_string):
220220
parser.add_argument(
221221
"cmdline_args", type=str, nargs="*", help="Arguments to the executable"
222222
)
223+
return parser
224+
225+
226+
def generate_config_from_cmdline(cmdline_string):
227+
parser = generate_parser()
223228
config = parser.parse_args(cmdline_string)
224229

225230
return config

0 commit comments

Comments
 (0)