Skip to content

Commit 1c8ea01

Browse files
authored
Merge pull request #1 from rothos/version-1.0.0
Version 1.0.0
2 parents f4b1e6d + 5f3df71 commit 1c8ea01

File tree

6 files changed

+714
-480
lines changed

6 files changed

+714
-480
lines changed

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1+
.DS_Store
2+
13
output/*
24
input_samples/*
5+
6+
# Python
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class
10+
*.so
11+
.Python
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
28+
# Virtual Environment
29+
venv/
30+
env/
31+
ENV/
32+
33+
# IDE
34+
.idea/
35+
.vscode/
36+
*.swp
37+
*.swo
38+
39+
# Testing
40+
.coverage
41+
htmlcov/
42+
.pytest_cache/

README.md

Lines changed: 33 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,44 @@
66
# Megamap
77

88
Megamap is a mega awesome version of the minimap feature of text editors like
9-
Sublime and Atom. Give megamap a directory full of source code, and it will
9+
Sublime. Give megamap a directory full of source code, and it will
1010
produce a PNG image which is a beautiful birdseye view of all the source code.
1111

1212

1313

1414
## Installation
1515

16-
Download this repository. Make sure you have Python 3. Maybe you need Python
17-
3.6 or something, I don't know.
18-
19-
You'll need to install some packages, the names of which you can figure out by
20-
the error messages you get when you try to run the script. At least these:
21-
```
22-
$ pip3 install drawSvg
23-
$ pip3 install pygments
16+
```bash
17+
pip install megamap
2418
```
25-
Maybe Cairo something too. It's 5am and I don't remember anything.
26-
27-
2819

29-
## Getting started
20+
## Usage
3021

31-
Put your input (could be any text files; source code works well -- although
32-
maybe a book of poetry would be cool too) into a subdirectory of the project,
33-
call it `input/`. Then run
22+
```bash
23+
megamap [input_directory] [output_filename]
3424
```
35-
$ python3 gen.py
36-
```
37-
If you're lucky it'll work. There might be errors. This has not been
38-
extensively tested. In fact, I just now got it working.
3925

40-
At the beginning of the script there are a bunch of (what I hope are)
41-
self-explanatory options. (A "page" is a column of the output image.)
26+
Optional arguments:
4227
```
43-
opts = {
44-
"input_directory": 'input',
45-
"output_filename": 'output.png',
46-
"ignore_hidden": True, # ignore hidden files & folders
47-
"style": get_style_by_name('monokai'),
48-
"use_zebra_bg": False, # if true, alternates bg colors among files
49-
"page_row_padding": 2, # row units (includes linespacing)
50-
"page_col_padding": 4, # column units
51-
"pagecols": 80, # column units
52-
"charheight": 1, # px
53-
"charwidth": 1, # px
54-
"linespacing": 1, # px
55-
"pixelscale": 1 # dimensionless
56-
}
57-
58-
# Aspect ratio is width/height. The program will calculate things to make the
59-
# aspect ratio as close as possible to what is specified. Right now it can't
60-
# guarantee exactness.
61-
opts["aspect_ratio"] = 1.5
28+
-h, --help Show this help message and exit
29+
-v, --verbose Enable verbose output
30+
-q, --quiet Suppress all output except errors
31+
--version Show program version number and exit
32+
--list-styles List available syntax highlighting styles and exit
33+
-a, --aspect-ratio Target aspect ratio (width/height) for output image (default: 1.5)
34+
-b, --banner Enable banner mode (sets aspect ratio to 5.0)
35+
--include-hidden Include hidden files and directories in the map
36+
-s, --style Syntax highlighting style (use "random" for random style)
37+
-z, --zebra Enable zebra striping of background colors between files
38+
-c, --cols Number of columns per page (default: 80)
39+
-x, --scale Pixel scale factor (must be integer, default: 1)
6240
```
6341

42+
The program will automatically:
43+
- Skip common non-code files (LICENSE, README, etc.)
44+
- Skip files with non-code extensions (.txt, .md, .json, etc.)
45+
- Skip binary and non-text files
46+
- Skip files without a valid syntax highlighter
6447

6548

6649
## Pretty pictures
@@ -83,34 +66,19 @@ Source code of entire projects can be elegantly illustrated:
8366
</p>
8467

8568

69+
## FAQ
8670

87-
## Questions I might ask myself in the future when I come back and look at this
88-
89-
### How do I find out what all the syntax highlighting styles are called?
90-
91-
```
92-
from pygments.styles import STYLE_MAP
93-
STYLE_MAP.keys()
94-
```
95-
I get this output:
96-
```
97-
dict_keys(['default', 'emacs', 'friendly', 'colorful', 'autumn', 'murphy', 'manni', 'monokai', 'perldoc', 'pastie', 'borland', 'trac', 'native', 'fruity', 'bw', 'vim', 'vs', 'tango', 'rrt', 'xcode', 'igor', 'paraiso-light', 'paraiso-dark', 'lovelace', 'algol', 'algol_nu', 'arduino', 'rainbow_dash', 'abap', 'solarized-dark', 'solarized-light', 'sas', 'stata', 'stata-light', 'stata-dark', 'inkpot'])
98-
```
99-
100-
### Can you sort the input files somehow?
71+
### How are the files sorted?
10172

102-
The `pathlib` module seems to order them out randomly, it's weird. But yeah
103-
there is no built-in feature to do this. It wouldn't be hard to modify the
104-
code to do it.
73+
The files are sorted alphabetically by directory and then by file name,
74+
with files in the base directory first.
10575

106-
### Is there a way to put a pretty border or frame around the image?
76+
### How do I find out what all the syntax highlighting styles are called?
10777

108-
Not right now. Try imagemagick or something. Or submit a pull request.
78+
You can either:
79+
1. Run `megamap --list-styles` to see all available styles
80+
2. Use `random` as the style to let megamap choose one randomly
10981

11082
### What about word wrapping?
11183

112-
Hahahaha.
113-
114-
Hahahahahahaahahahahahahahahahaahahaha.
115-
116-
No.
84+
Not currently supported.

0 commit comments

Comments
 (0)