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 followincludepaths).
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-mermaidandpatch-package) copy-to-clipboardfor copying text to the clipboardfile-saverfor downloading filesis-iosfor detecting iOS devices- Vitest for testing
- Prettier 3 for code formatting
patch-packagefor patching NPM packagesgh-pagesfor deploying the app
This code base was bootstrapped by running:
npx --yes create-vite monocle --template react-tsThe originally-generated
README.mdfile 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 testTests are written using Vitest.
npm run prettierThere 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-parserJavaScript 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-mermaidpackage
The file, patches/mdx-mermaid+2.0.0.patch, was generated by performing the following steps:
- Add
"postinstall": "patch-package"topackage.json'sscriptsobject - Edit
node_modules/mdx-mermaid/package.json(as documented in the patch file) - Run
$ npx patch-package --exclude '^$' mdx-mermaidto generate the patch file
- Bump
versionnumber inpackage.jsonandpackage-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_VERSIONat 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
Makefilecontent (non-React example) - Allow the user to load a
Makefileby entering its URL into a textbox (users can already enter it via query string) - Allow the user to upload a
Makefileby browsing for it on their computer (users can already drag-and-drop one) - Allow user to choose the graph direction (
TBversusLR) (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
Makefileloaded 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.