gitgraph-minigram

0.3.0 • Public • Published

gitgraph-minigram

Provides grammar and parser for git commands (made with pegjs), and API invoker for @gitgraph/js.

This library takes the approach to draw commit graph from the sequence of git command inputs as you usually use in terminal.

Grammar

Input text consists of 2 sections: [option] and [log].

Basic structure of input

  • [option] is optional.
[option]
defaultBranch: <branch>
[log]
...
[log]
...

Options in [option] section

key value default
defaultBranch string master

Supported git commands in [log] section

git commit
git commit -m '<message>'
git commit -m "<message>"
git branch <branch>
git checkout <branch>
git checkout -b <branch>
git switch <branch>
git switch -c <branch>
git merge <branch>
git tag <tag>

Basic usage

import { createGitgraph } from '@gitgraph/js';
import { Format2Parser, Generator } from 'gitgraph-minigram';

const parser = new Format2Parser();
const generator = new Generator();

const input = ...; // Prepare text written in above grammar.
const parseResult = parser.parse(input);

if (parseResult.parsed()) {
  const container = ...; // HTML element to draw git commit graph.
  const graph = createGitgraph(container);

  generator.generate(graph, parseResult.getParseData());
} else {
  const e = parseResult.getError(); // pegjs syntax error object.
}

Used by

Readme

Keywords

Package Sidebar

Install

npm i gitgraph-minigram

Weekly Downloads

0

Version

0.3.0

License

MIT

Unpacked Size

173 kB

Total Files

19

Last publish

Collaborators

  • smori1983