Skip to content

Commit e819b83

Browse files
authored
Merge pull request #127 from ncusi/documentation - improve API and CLI documentation
Documentation: Improve automatically generated documentation (for https://ncusi.github.io/PatchScope)
2 parents ee8c5e8 + cb680ae commit e819b83

15 files changed

Lines changed: 1523 additions & 727 deletions

File tree

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Check out our [video demonstration](https://youtu.be/8fj8Mgv-72s) on YouTube.
2727

2828
## Disambiguation
2929

30-
There are a few projects research projects with a similar name:
30+
There are a few research projects with a similar name:
3131

3232
- Asma Ghandeharioun, Avi Caciularu, Adam Pearce, Lucas Dixon, Mor Geva:
3333
_"Patchscopes: A Unifying Framework for Inspecting Hidden Representations of Language Models"_ (2024)
@@ -82,9 +82,9 @@ See also the ["Development"](#development) section below.
8282

8383
This tool integrates four key components
8484

85-
1. extracting patches from version control system or user-provided folders<br>
85+
1. extracting patches from a version control system or user-provided folders<br>
8686
either as separate step with `diff-generate`,
87-
or integrated into annotation step (`diff-annotate`)
87+
or integrated into the annotation step (`diff-annotate`)
8888
2. applying specified annotation rules for selected patches<br>
8989
using `diff-annotate`, which generates one JSON data file per patch
9090
3. generating configurable reports or summaries<br>
@@ -97,11 +97,11 @@ analyze individual patch files,
9797
enhance patch-based datasets,
9898
and monitor contributions to repositories.
9999
The process for those use cases differs in details;
100-
here is quick start tutorial for the case of repository contribution analysis.
100+
here is a quick start tutorial for the case of repository contribution analysis.
101101

102102
### Quick start: analyzing repository
103103

104-
First step is to clone the repository you want to analyze,
104+
The first step is to clone the repository you want to analyze,
105105
if not already present. Let's assume that you want to
106106
get insights about [tqdm][] project development.
107107
```commandline
@@ -114,7 +114,7 @@ The clone might be bare.
114114
Second step is to generate annotations with `diff-annotate from-repo`.
115115
This might take a while for a larger repository, like the Linux kernel.
116116
You can use [Git revision selection](https://git-scm.com/docs/gitrevisions)
117-
arguments to select changes to annotate; for example you can use
117+
arguments to select changes to annotate; for example, you can use
118118
`--max-parents=1` to drop merges,
119119
and `--after=2020.01.01` to limit date range.
120120
```commandline
@@ -125,7 +125,7 @@ diff-annotate from-repo \
125125

126126
Third step is to generate summary of annotations with `diff-gather-stats`,
127127
gathering statistics into a single JSON file.
128-
For repository visualization you will need at least the timeline.
128+
For repository visualization, you will need at least the timeline.
129129
```commandline
130130
diff-gather-stats --annotations-dir='' \
131131
timeline \
@@ -140,7 +140,7 @@ diff-gather-stats --annotations-dir='' \
140140
```
141141

142142
If you want to see Sankey flow diagram in the visualization,
143-
you need also to generate summary of changed lines statistics.
143+
you need also to generate a summary of changed lines statistics.
144144
```commandline
145145
diff-gather-stats --annotations-dir='' \
146146
lines-stats \
@@ -163,7 +163,7 @@ _"[Annotation process](docs/annotation_process.md)"_ documentation.
163163

164164
### Running web app (dashboard)
165165

166-
This package also includes web dashboard, created using the [Panel][]
166+
This package also includes a web dashboard, created using the [Panel][]
167167
framework. You would need to install additional dependencies, denoted `[web]`,
168168
as described above.
169169

@@ -176,10 +176,10 @@ diffinsights-web stats/
176176
```
177177
Then open `http://localhost:7860/?repo=tqdm` in a web browser.
178178

179-
Currently, this web dashboard consist of two pages (two web apps),
180-
namely Contributors Graph and Author Statistics.
179+
Currently, this web dashboard consists of two pages (two web apps),
180+
namely the Contributors Graph and the Author Statistics.
181181

182-
You can find description of those two pages/apps, with screenshots,
182+
You can find the description of those two pages/apps, with screenshots,
183183
in [PatchScope documentation](https://ncusi.github.io/PatchScope/contributors_graph/):
184184
- [`docs/author_statistics.md`](docs/author_statistics.md)
185185
- [`docs/contributors_graph.md`](docs/contributors_graph.md)
@@ -193,7 +193,7 @@ directory.
193193
You can download data for more repos from <https://dagshub.com/ncusi/PatchScope>
194194
with [DVC][], see the ["Examples and demos"](#examples-and-demos) section below.
195195

196-
There is web app demo available for those repos at <http://patchscope.mat.umk.pl/>,
196+
There is a web app demo available for those repos at <http://patchscope.mat.umk.pl/>,
197197
and also basic [demo on Heroku](https://patchscope-9d05e7f15fec.herokuapp.com/).
198198

199199
The simplest solution to run those demos locally is to clone
@@ -246,7 +246,7 @@ you can change parameters to better fit your environment:
246246

247247
This project uses [DVC](https://dvc.org/) (Data Version Control) tool
248248
to track annotations and metrics data, and version this data. It allows
249-
to store large files and large directories outside of Git repository,
249+
storing large files and large directories outside of Git repository,
250250
while still have them to be version controlled. They can be stored locally,
251251
or in the cloud.
252252

@@ -270,7 +270,7 @@ in _DVC cache_, and you can push them to _DVC remote_ with `dvc push`, if you ha
270270
one configured (the `examples-init.bash` script from previous subsection
271271
configures DVC remote with storage on the local filesystem).
272272

273-
<!-- TODO: add figure about how DVC works -->
273+
<!-- TODO: add a figure about how DVC works -->
274274

275275
### Downloading data from DAGsHub
276276

@@ -327,7 +327,7 @@ a [virtual environment][venv], for example with:
327327
python -m venv .venv
328328
```
329329

330-
This needs to be done only once, from top directory of the project.
330+
This needs to be done only once, from the top directory of the project.
331331
For each session, you should activate the environment:
332332
```commandline
333333
source .venv/bin/activate
@@ -345,7 +345,7 @@ packages, but Python is configured in a very specific way:
345345

346346
### Installing the package in editable mode
347347

348-
To install the project in editable mode (from top directory of this repo):
348+
To install the project in editable mode (from the top directory of this repo):
349349
```commandline
350350
python -m pip install -e .
351351
```
@@ -437,7 +437,7 @@ Tools to generate HTML dashboard, or providing an interactive web application:
437437
**note** that [gitstats.me](https://gitstats.me/) no longer works
438438
(the domain is parked for sale)
439439
- [`repostat`](https://github.com/vifactor/repostat)
440-
is Git repository analyser and HTML-report generator
440+
is Git repository analyzer and HTML-report generator
441441
with [NVD3](https://nvd3.org/)-driven interactive metrics visualisations;<br>
442442
**note** that demo site <https://repostat.imfast.io/> no longer works
443443
- [NVD3.js](https://nvd3.org/) is an attempt to build re-usable charts
@@ -451,7 +451,7 @@ Tools to generate HTML dashboard, or providing an interactive web application:
451451
- [cregit](https://github.com/cregit/cregit)
452452
is a tool for helping to find and analyse code credits
453453
(unify identities, find contribution by token,
454-
extract metadata into a SQLite database, etc.)
454+
extract metadata into an SQLite database, etc.)
455455
- [Githru](https://github.com/githru/githru) is an interactive visual analytics system
456456
that enables developers to effectively understand the context of development history
457457
through the [interactive exploration of Git and GitHub metadata (demo)](https://githru.github.io/demo/).

TODO.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@
2929
- [x] add `docs/` directory (for man pages, and maybe API documentation)
3030
- [x] use [MkDocs][] or [Material for MkDocs][mkdocs-material] for general documentation
3131
- [x] generate API documentation using [mkdocstrings][]
32-
- [ ] switch from Sphinx/reST format to better supported Numpydoc format
32+
- [x] switch from Sphinx/reST format to a better supported Numpydoc format
3333
with [docconvert](https://github.com/cbillingham/docconvert)
3434
or [pyment](https://github.com/dadadel/pyment)
35-
- [x] generate documentation for scripts using [mkdocs-typer][]
35+
- [x] generate documentation for scripts using [mkdocs-typer2][]
3636
([typer][] is used for parsing CLI arguments)
37-
- [ ] replace it with a better solution, e.g. from the next point
3837
- [ ] _maybe_ generate manpages from MkDocs with [mkdocs-manpage][] (at least for scripts)
3938
- [ ] _maybe_ include gallery of examples with [mkdocs-gallery](https://smarie.github.io/mkdocs-gallery/)
4039
- [ ] _maybe_ CLI demos with [Asciinema][], or one of the alternatives, like
@@ -356,7 +355,7 @@ data.
356355
[mkdocs-material]: https://squidfunk.github.io/mkdocs-material/ "Material for MkDocs: Documentation framework on top of MkDocs"
357356
[mkdocstrings]: https://mkdocstrings.github.io/ "mkdocstrings: Automatic documentation from sources, for MkDocs"
358357
[mkdocs-manpage]: https://pawamoy.github.io/mkdocs-manpage/ "MkDocs Manpage: MkDocs plugin to generate a manpage from the documentation site"
359-
[mkdocs-typer]: https://github.com/bruce-szalwinski/mkdocs-typer "mkdocs-typer: An MkDocs extension to generate documentation for Typer command line applications"
358+
[mkdocs-typer2]: https://github.com/syn54x/mkdocs-typer2 "mkdocs-typer2: MkDocs plugin for Typer CLI docs"
360359
[Asciinema]: https://asciinema.org/ "Asciinema - Record and share your terminal sessions, the simple way"
361360
[Terminalizer]: https://www.terminalizer.com/ "Terminalizer: Record your terminal and generate animated gif images or share a web player"
362361
[ttyrec]: http://0xcc.net/ttyrec/ "ttyrec: a tty recorder"

docs/cli.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,37 @@
22

33
This page provides documentation for PatchScope command line tools.
44

5+
The PatchScope includes four key elements, each with the corresponding
6+
CLI (Command Line Interface) tool:
57

6-
[//]: # (see https://github.com/bruce-szalwinski/mkdocs-typer/issues/18)
8+
1. extracting patches from a version control system or user-provided folders<br>
9+
either as separate step with [`diff-generate`](#diff-generate),
10+
or integrated into the annotation step ([`diff-annotate`](#diff-annotate))
11+
2. applying specified annotation rules for selected patches<br>
12+
using [`diff-annotate`](#diff-annotate), which generates one JSON data file per patch
13+
3. generating configurable reports or summaries<br>
14+
with various subcommands of [`diff-gather-stats`](#diff-gather-stats);
15+
each summary is saved as a single JSON file
16+
4. advanced visualization with a web application (dashboard),<br>
17+
(using the summaries generated in the previous step),
18+
which you can run it with `panel serve`, or [`diffinsights-web`](#diffinsights-web)
719

8-
::: mkdocs-typer
20+
[//]: # (see https://github.com/syn54x/mkdocs-typer2)
21+
22+
::: mkdocs-typer2
923
:module: diffannotator.generate_patches
10-
:command: app
11-
:prog_name: diff-generate
24+
:name: diff-generate
1225

13-
::: mkdocs-typer
26+
::: mkdocs-typer2
1427
:module: diffannotator.annotate
15-
:command: app
16-
:prog_name: diff-annotate
28+
:name: diff-annotate
1729

18-
::: mkdocs-typer
30+
::: mkdocs-typer2
1931
:module: diffannotator.gather_data
20-
:command: app
21-
:prog_name: diff-gather-stats
32+
:name: diff-gather-stats
33+
34+
<hr>
35+
36+
::: mkdocs-typer2
37+
:module: diffinsights_web.main
38+
:name: diffinsights-web

mkdocs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ markdown_extensions:
9393
permalink: true
9494
slugify: !!python/name:pymdownx.slugs.uslugify
9595
- meta
96-
- mkdocs-typer # generate documentation for Typer command line applications
9796
plugins:
9897
- include-markdown # including (embedding) Markdown files, by default within {% and %}
9998
- search: # adds a search bar to the header; powered by lunr.js
10099
lang: en
101100
- mkdocs-jupyter # use Jupyter Notebooks in mkdocs
101+
- mkdocs-typer2 # generate documentation for Typer command line applications
102102
# automatic generation of files for mkdocstrings
103103
# see https://mkdocstrings.github.io/recipes/#automatic-code-reference-pages
104104
- gen-files: # generate mkdocstrings pages on-the-fly
@@ -116,8 +116,8 @@ plugins:
116116
paths: [ "src" ]
117117
options:
118118
show_bases: true
119-
docstring_style: sphinx
120-
#docstring_section_style: spacy
119+
docstring_style: numpy
120+
docstring_section_style: spacy
121121
show_signature: true
122122
separate_signature: true
123123
show_signature_annotations: true

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ doc = [
7575
"mkdocs-gen-files~=0.5.0",
7676
"mkdocs-literate-nav~=0.6.1",
7777
"mkdocs-section-index~=0.3.9",
78-
"mkdocs-typer~=0.0.3",
78+
"mkdocs-typer2~=0.1.4",
7979
"mkdocs-material~=9.6.7",
8080
"mkdocs-jupyter~=0.25.1",
8181
#"mike~=1.1.2",

0 commit comments

Comments
 (0)