Skip to content

Commit a7b775a

Browse files
Js (#23)
* javascript working for most basic script * 'this' is working better * progress * progress * tests pass. JS almost at same level as Python * module type for js * 100% js coverage * tweaks to engine * remove unneeded test * readme tweak * version tweaks * JS at 100%. Generalized find_links and simplified implementations a bit more * js cleanup. Almost ready * clean up naming * further simplify. In a good place for remaining two languages * small tweaks * fix from first Kentaro review * sync the BaseLanguage with new reality. Fix test_bad_acorn * source_type on abstract class addressed * small fixes for chart.js * js merge in progress * pull in two more things * finish merge * fix cli and test for skip_parse_errors * Chart.js renders * small inherits fix for js * remove unneeded line in get_ast.js * proper version bumping
1 parent adcc707 commit a7b775a

File tree

42 files changed

+7858
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+7858
-241
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ htmlcov
66
build/
77
*.egg-info
88
dist
9+
composer.json
10+
composer.lock
11+
vendor

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Code2flow CHANGELOG
22

3+
## [2.1.0] - 2021-06-15
4+
Javascript support
5+
36
## [2.0.1] - 2021-05-30
47
Add support for constructors to Python
58

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
test:
2-
pytest --cov-report=html --cov=lib
2+
pytest --cov-report=html --cov=lib -x
33

44
clean:
55
rm -rf build

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
![code2flow logo](assets/code2flowlogo.png)
22

3-
![Version 2.0.1](https://img.shields.io/badge/version-2.0.1-brightgreen) ![Build passing](https://img.shields.io/badge/build-passing-brightgreen) ![Coverage 100%](https://img.shields.io/badge/coverage-100%25-brightgreen) ![License MIT](https://img.shields.io/badge/license-MIT-green])
3+
![Version 2.1.0](https://img.shields.io/badge/version-2.1.0-brightgreen) ![Build passing](https://img.shields.io/badge/build-passing-brightgreen) ![Coverage 100%](https://img.shields.io/badge/coverage-100%25-brightgreen) ![License MIT](https://img.shields.io/badge/license-MIT-green])
44

55
> #### Updates from May 2021
66
> - I've entered into a contract with a generous sponsor, the [Sider Corporation](https://siderlabs.com), to update code2flow.
7-
> - This version runs Python3. Javascript support has been dropped temporarily. If you want javascript support for pre-ES6 projects, check out commit 258952d7123f946d320a83de3af75e7b96ea1a45.
8-
> - Going forward, in addition to JS, expect support for PHP8, & Ruby3
7+
> - Currently, Code2flow supports Python and JS. Expect PHP & Ruby in the coming weeks.
98
> - The domain, code2flow.com is unrelated to this project and as far as I can tell through the internet archive, they launched their service after this repository was created. I've never heard anything from them and it doesn't appear like they use anything from here.
109
> - The pip install, code2flow, has been claimed by a different unrelated project. For now, *don't install* code2flow from pip. Instead, scroll to the installation section for instructions.
1110
@@ -26,12 +25,12 @@ Code2flow will provide a *pretty good estimate* of your project's structure. No
2625

2726
*(Below: Code2flow running on itself (excl javascript, PHP, & Ruby for clarity))*
2827

29-
![code2flow running against itself TODO abspath https://raw.githubusercontent.com/scottrogowski/code2flow/master/assets/code2flow_output.png](assets/code2flow_output.png)
28+
![code2flow running against itself](https://raw.githubusercontent.com/scottrogowski/code2flow/master/assets/code2flow_output.png)
3029

3130
Installation
3231
------------
3332

34-
For now, do _not_ pip install. The *code2flow* name is held by a different project. Instead, run:
33+
For now, _do not pip install_. The *code2flow* name is held by a different project. Instead, run:
3534

3635
```bash
3736
python setup.py install

assets/code2flowlogo.png

4.04 KB
Loading

code2flow

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import argparse
44
import logging
55

6-
from lib.engine import code2flow, VALID_EXTENSIONS, VERSION
6+
from lib.engine import code2flow, VALID_EXTENSIONS, VERSION, LanguageParams
77

88
DESCRIPTION = "Generate flow charts from your source code. " \
99
"See the README at https://github.com/scottrogowski/code2flow."
@@ -20,7 +20,7 @@ if __name__ == "__main__":
2020
'--output', '-o', default='out.png',
2121
help=f'output file path. Supported types are {VALID_EXTENSIONS}.')
2222
parser.add_argument(
23-
'--language', choices=['py', 'js'],
23+
'--language', choices=['py', 'js', 'rb'],
2424
help='process this language and ignore all other files.'
2525
'If omitted, use the suffix of the first source file.')
2626
parser.add_argument(
@@ -38,6 +38,15 @@ if __name__ == "__main__":
3838
parser.add_argument(
3939
'--hide-legend', action='store_true',
4040
help='by default, Code2flow generates a small legend. This flag hides it.')
41+
parser.add_argument(
42+
'--skip-parse-errors', action='store_true',
43+
help='skip files that the language parser fails on.')
44+
parser.add_argument(
45+
'--source-type', choices=['script', 'module'], default='script',
46+
help='js only. Parse the source as scripts (commonJS) or modules (es6)')
47+
parser.add_argument(
48+
'--ruby-version', default='27',
49+
help='ruby only. Which ruby version to parse? This is passed directly into ruby-parse. Use numbers like 25, 27, or 31.')
4150
parser.add_argument(
4251
'--quiet', '-q', action='store_true',
4352
help='suppress most logging')
@@ -58,7 +67,9 @@ if __name__ == "__main__":
5867

5968
exclude_namespaces = list(filter(None, (args.exclude_namespaces or "").split(',')))
6069
exclude_functions = list(filter(None, (args.exclude_functions or "").split(',')))
70+
lang_params = LanguageParams(args.source_type, args.ruby_version)
6171

6272
code2flow(args.sources, args.output, args.language, args.hide_legend,
6373
exclude_namespaces, exclude_functions,
64-
args.no_grouping, args.no_trimming, level)
74+
args.no_grouping, args.no_trimming, args.skip_parse_errors,
75+
lang_params, level)

0 commit comments

Comments
 (0)