@markw65/prettier-plugin-monkeyc 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +96 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @markw65/prettier-plugin-monkeyc
2
+
3
+ A prettier plugin for formatting monkey-c code.
4
+
5
+ ## Intro
6
+
7
+ Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
8
+
9
+ This plugin adds support for the monkey-c language to Prettier.
10
+
11
+ ### Input
12
+
13
+ ```
14
+ dc.drawText(_width/2, 3,Graphics.FONT_TINY, "Ax = "+_accel[0], Graphics.TEXT_JUSTIFY_CENTER);
15
+ ```
16
+
17
+ ### Output
18
+
19
+ ```
20
+ dc.drawText(
21
+ _width / 2,
22
+ 3,
23
+ Graphics.FONT_TINY,
24
+ "Ax = " + _accel[0],
25
+ Graphics.TEXT_JUSTIFY_CENTER
26
+ );
27
+ ```
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ npm install --save-dev @markw65/prettier-plugin-monkeyc
33
+
34
+ # or globally
35
+
36
+ npm install --global @markw65/prettier-plugin-monkeyc
37
+ ```
38
+
39
+ ## Use
40
+
41
+ ### With VSCode
42
+
43
+ Install the Prettier extension from https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode. If you installed globally, it should just work. VSCode's `Format Document` command (`Option-Shift-F`) will reformat your .mc files for you. If you installed locally, you'll need to tell the extension to use the local prettier. Put `"prettier.prettierPath": "./node_modules/prettier"` in your `.vscode/settings.json` file.
44
+
45
+ ### With Node.js
46
+
47
+ If you installed prettier as a local dependency, you can run it via
48
+
49
+ ```bash
50
+ npx prettier path/to/code.mc --write
51
+ ```
52
+
53
+ If you installed globally, run
54
+
55
+ ```bash
56
+ prettier path/to/code.mc --write
57
+ ```
58
+
59
+ ## Options
60
+
61
+ The standard Prettier options (such as `tabWidth`) can be used.
62
+
63
+ ## Development
64
+
65
+ To make a production build, run
66
+
67
+ ```
68
+ npm run build-release
69
+ ```
70
+
71
+ To develop, run
72
+
73
+ ```
74
+ npm run build-debug
75
+ ```
76
+
77
+ You can then execute Prettier with
78
+
79
+ ```
80
+ npx prettier [ --write ] --plugin build/prettier-plugin-monkeyc.cjs ...
81
+ ```
82
+
83
+ ### Code structure
84
+
85
+ `@markw65/prettier-plugin-monkeyc` uses a Peggy grammar (located in `peg/`)
86
+ to parse monkeyc. This grammar was originally copied from the Peggy sample javascript grammar, and still has some javascript features that aren't relevant to monkeyc. I'm planning to clean that up, but for now it shouldn't matter.
87
+
88
+ `@markw65/prettier-plugin-monkeyc` is written in native ES6 javascript, and uses webpack to dynamically compile to commonjs, because thats what prettier wants.
89
+
90
+ The plugin is organized as follows:
91
+
92
+ - `prettier-plugin-monkeyc.js` This file exports the objects required of a
93
+ Prettier plugin.
94
+ - `peg/monkeyc.peggy` The Peggy grammar for monkey-c.
95
+ - `src/printer.js` Printers take an AST and produce a Doc (the intermediate
96
+ format that Prettier uses). This is currently a thin wrapper around Prettier's default, estree printer. It handles just the nodes that it needs to, and delegates to "javascript-like" behavior for everything else.
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "pretty": "prettier --plugin build/prettier-plugin-monkeyc.cjs example/AnalogView.mc"
19
19
  },
20
20
  "name": "@markw65/prettier-plugin-monkeyc",
21
- "version": "1.0.0",
21
+ "version": "1.0.1",
22
22
  "description": "A prettier plugin for Garmin monkey-c",
23
23
  "main": "build/prettier-plugin-monkeyc.cjs",
24
24
  "files": [