Monocle is a Makefile
visualizer for the web.
You can use it to view a Makefile
as a graph of its targets and their dependencies—in your web browser.
Monocle has the following limitations:
- It only parses a single
Makefile
(i.e. it does not followinclude
paths).
Monocle is built upon the following technologies:
- Node 20
- Vite 4
- React 18
- TypeScript 5
- Bootstrap 5 (via
react-bootstrap
) - Bootstrap Icons (via
bootstrap-icons
) - Codemirror 6 (via
@uiw/react-codemirror
) - Mermaid (via
mdx-mermaid
andpatch-package
) copy-to-clipboard
for copying text to the clipboardfile-saver
for downloading filesis-ios
for detecting iOS devices- Vitest for testing
- Prettier 3 for code formatting
patch-package
for patching NPM packagesgh-pages
for deploying the app
This code base was bootstrapped by running:
npx --yes create-vite monocle --template react-ts
The originally-generated
README.md
file has been archived toREADME.bak.md
.
The favicon (public/favicon.ico
) was generated by favicon.io, using the following settings:
- Text:
m
- Background:
Rounded
- Font Family:
Leckerli One
- Font Variant:
Regular 400 Normal
- Font Size:
110
- Font Color:
#FFFFFF
- Background Color:
#212529
(i.e. the same color as Bootstrap's dark theme background; i.e.--bs-body-bg
)
- Node 20 is installed
- Install NPM dependencies
npm install
- Start development server
npm run dev
- Visit: http://localhost:5173/monocle/
npm test
Tests are written using Vitest.
npm run prettier
There are two types of patches in this repository:
- Those managed manually (these are all in
src/patches/
)src/patches/@kba/makefile-parser/index.d.ts
: TypeScript information for the@kba/makefile-parser
JavaScript package
- Those managed using
patch-package
(these are all inpatches/
)patches/mdx-mermaid+2.0.0.patch
: A patch file to work around the TypeScript#52363 issue for themdx-mermaid
package
The file, patches/mdx-mermaid+2.0.0.patch
, was generated by performing the following steps:
- Add
"postinstall": "patch-package"
topackage.json
'sscripts
object - Edit
node_modules/mdx-mermaid/package.json
(as documented in the patch file) - Run
$ npx patch-package --exclude '^$' mdx-mermaid
to generate the patch file
- Bump
version
number inpackage.json
andpackage-lock.json
# Alternatively, you can specify `major` or `minor` instead of `patch`. npm version --git-tag-version false patch
The version number will accessible via
PACKAGE_VERSION
at build time (more info) - (Optional) Generate and preview the production build
npm run build npm run preview
Then visit: http://localhost:4173/monocle/
- Generate and deploy a production build
npm run deploy
- Apply syntax highlighting to the
Makefile
content (non-React example) - Allow the user to load a
Makefile
by entering its URL into a textbox (users can already enter it via query string) - Allow the user to upload a
Makefile
by browsing for it on their computer (users can already drag-and-drop one) - Allow user to choose the graph direction (
TB
versusLR
) (users can already copy then edit the Mermaid code) - Allow user to choose whether to download "light" or "dark" diagram, regardless of current website theme
- Style targets and non-targets distinctly from one another in the diagram
- Implement a mode optimized for viewing (the diagram of) a
Makefile
loaded from a URL specified via query params - Maybe: Store current Makefile in browser storage (refreshing the page currently discards the Makefile content)
- Maybe: Add SVG pan and zoom
- Q: Why'd you name it "monocle?"
- A: I went with the word "monocle" because its "m", "k", and "l" sounds are in the same order as in the word "Makefile", and a monocle is a thing people use to see things in a different way.