Skip to content

Commit

Permalink
Merge pull request #26 from bvobart/mllint-site
Browse files Browse the repository at this point in the history
Adds source code for mllint's GitHub Pages website
  • Loading branch information
bvobart authored Jul 28, 2021
2 parents a06595c + 273ad44 commit 7fd388a
Show file tree
Hide file tree
Showing 26 changed files with 1,471 additions and 6 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Publish mllint's GitHub Pages website

# Runs on
# - pushes to master with changes to the files in docs/gh-pages or this file
# - release tags
on:
push:
branches:
- master
paths:
- docs/gh-pages
- .github/workflows/gh-pages.yml
tags:
- "v*"

jobs:
publish:
name: Build and publish mllint's website to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: ^1.16

- uses: actions/checkout@v2
with:
submodules: true # Fetch Hugo theme (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

- uses: actions/cache@v2
with:
# In order:
# * Go module download cache
# * Go build cache (Linux)
path: |
~/go/pkg/mod
~/.cache/go-build
key: ubuntu-latest-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
ubuntu-latest-go-
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.85.0'
extended: true

- name: Generate Categories & Rules documentation
run: go run ./docs/gh-pages/scripts/generate-docs.go

- name: Build website (tagged version)
if: startsWith(github.ref, 'refs/tags/v')
working-directory: docs/gh-pages/
env:
HUGO_MLLINT_VERSION: ${GITHUB_REF#refs/tags/v}
run: |
echo "> mllint version: $HUGO_MLLINT_VERSION"
hugo --minify
- name: Build website (regular commit)
if: startsWith(github.ref, 'refs/heads/')
working-directory: docs/gh-pages/
run: |
export HUGO_MLLINT_VERSION=$(git describe --tags)
echo "> mllint version: $HUGO_MLLINT_VERSION"
hugo --minify
- name: Deploy website
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/gh-pages/public/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "docs/gh-pages/themes/PaperMod"]
path = docs/gh-pages/themes/PaperMod
url = https://github.com/adityatelange/hugo-PaperMod.git
15 changes: 10 additions & 5 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# `mllint` — Linter for Machine Learning projects
# [`mllint` — Linter for Machine Learning projects](https://bvobart.github.io/mllint/)

<p align="center">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/bvobart/mllint/Build%20mllint%20and%20upload%20to%20PyPI">
<img alt="GitHub go.mod Go version" src="https://img.shields.io/github/go-mod/go-version/bvobart/mllint">
<a href="https://pkg.go.dev/github.com/bvobart/mllint"><img src="https://pkg.go.dev/badge/github.com/bvobart/mllint.svg" alt="Go Reference"></a>
<a href="https://codecov.io/gh/bvobart/mllint"><img alt="Code coverage" src="https://codecov.io/gh/bvobart/mllint/branch/main/graph/badge.svg?token=K9PJMGMFVI"/></a>
<a href="https://goreportcard.com/report/github.com/bvobart/mllint"><img alt="GoReportCard" src="https://goreportcard.com/badge/github.com/bvobart/mllint"/></a>
<img alt="Platform" src="https://img.shields.io/badge/platform-Linux%20%7C%20MacOS%20%7C%20Windows-informational">
</p>
<p align="center">
Expand All @@ -25,11 +26,13 @@

`mllint` is created during my MSc thesis in Computer Science at the Software Engineering Research Group ([SERG](https://se.ewi.tudelft.nl/)) at [TU Delft](https://tudelft.nl/) and [ING](https://www.ing.com/)'s [AI for FinTech Research Lab](https://se.ewi.tudelft.nl/ai4fintech/) on the topic of _Code Quality and Software Engineering for Machine Learning projects_

<p align="center"><img src="./docs/example-run.svg"></p>
<p align="center"><img src="./docs/gh-pages/static/example-run.svg"></p>

> See [`docs/example-report.md`](docs/example-report.md) to view the report generated for this example project.
>
> See also the [`mllint-example-projects`](https://github.com/bvobart/mllint-example-projects) repository to explore the reports of an example project using `mllint` to measure and improve its project quality over several iterations.
>
> See also [`mllint`'s website](https://bvobart.github.io/mllint/) for online documentation of all of its linting rules and categories.
---

Expand Down Expand Up @@ -62,9 +65,9 @@ pip install --upgrade mllint[tools]

### Docker

There are also `mllint` Docker containers available on [Docker Hub](https://hub.docker.com/r/bvobart/mllint) at `bvobart/mllint` for Python 3.6, 3.7, 3.8 and 3.9. They require that you mount the folder with your project onto the container as a volume on `/app`.
There are also `mllint` Docker containers available on [Docker Hub](https://hub.docker.com/r/bvobart/mllint) at `bvobart/mllint` for Python 3.6, 3.7, 3.8 and 3.9. These may particularly be helpful when running `mllint` in CI environments, such as Gitlab CI or Github Actions. See the Docker Hub for a full list of available tags that can be used.

Here is an example of how to use this Docker container, assuming that your project is in the current folder. Replace `$(pwd)` with the full path to your project folder if it is somewhere else.
The Docker containers require that you mount the folder with your project onto the container as a volume on `/app`. Here is an example of how to use this Docker container, assuming that your project is in the current folder. Replace `$(pwd)` with the full path to your project folder if it is somewhere else.

```sh
docker run -it --rm -v $(pwd):/app bvobart/mllint:latest
Expand Down Expand Up @@ -116,6 +119,8 @@ To list all enabled linting rules, run (optionally providing the path to the pro
mllint list enabled
```

Alternatively, visit the [Categories](https://bvobart.github.io/mllint/docs/categories/) and [Rules](https://bvobart.github.io/mllint/docs/rules/) pages on [`mllint`'s website](https://bvobart.github.io/mllint/) to view the latest online documentation of these rules.

By default, all of `mllint`'s rules are enabled. See [Configuration](#configuration) to learn how to selectively disable certain rules.

To learn more about a certain rule or category, use `mllint describe` along with the slug of the category or rule:
Expand All @@ -135,7 +140,7 @@ mllint describe version-control/data
### Custom linting rules

It is also possible to define your own custom linting rules by implementing a script or program that `mllint` will run while performing its analysis.
These custom rules need to be defined in `mllint`'s configuration. For more information on how to do this, see `mllint describe custom`.
These custom rules need to be defined in `mllint`'s configuration. For more information on how to do this, see `mllint describe custom` or view the documentation online [here](https://bvobart.github.io/mllint/docs/categories/custom/).

---

Expand Down
7 changes: 7 additions & 0 deletions docs/gh-pages/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/content/docs/categories/*
!/content/docs/categories/_index.md

/content/docs/rules/*
!/content/docs/rules/_index.md

/public/
32 changes: 32 additions & 0 deletions docs/gh-pages/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# [`mllint`'s GitHub Pages website](https://bvobart.github.io/mllint/)

This directory contains the source code for `mllint`'s GitHub Pages website. It's a static website generated from Markdown files using [Hugo](https://gohugo.io/) and uses the [PaperMod](https://git.io/hugopapermod) theme with some custom tweaks and accent colours by me, Bart van Oort (@bvobart).

## Folder structure

```sh
.
├── assets # contains custom CSS and HighlightJS theme
├── content # contains all of the Markdown files that make up the content of the website. Part of it needs to be generated.
├── layouts # contains overridden layout files from the theme for some layout tweaks.
├── public # when the website is built, this is where it ends up
├── scripts # contains the scripts to generate the category and rule documentation files
├── static # contains static files, e.g. images.
├── themes # contains a submodule with the PaperMod theme
├── config.yml # Hugo's configuration file.
└── ReadMe.md
```

## Building & Developing

There's a GitHub Actions workflow (see `.github/workflows/gh-pages.yml` in this repo) that automatically builds and publishes this website on every push to `main` containing changes to this folder and on every pushed tag. The built website can be viewed on the `gh-pages` branch of this repo.

For developing this website, you'll want to be able to run it locally. To do so, make sure you have Go and [Hugo](https://gohugo.io/) installed. Then, from this folder (`docs/gh-pages`), run the following commands:

```sh
git submodule update --init # to download the theme
./scripts/clean-docs.sh && go run ./scripts/generate-docs.go # to generate the rules & categories documentation
hugo server # runs a development server, see http://localhost:1313/mllint/ when it's running
```

> Note: you can re-generate the rules & categories documentation _while_ the Hugo server is running and Hugo will pick up the changes automatically.
31 changes: 31 additions & 0 deletions docs/gh-pages/assets/css/extended/footer-version.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.footer-version {
font-size: 12px;
color: var(--secondary);
max-width: calc(var(--main-width) + var(--gap) * 2);
margin: auto;
padding-bottom: 8px;
text-align: center;
}

.footer {
padding-bottom: 4px;
}

.footer-version span {
margin-inline-start: 1px;
margin-inline-end: 1px;
}

.footer-version span:last-child {
white-space: nowrap;
}

.footer-version a {
color: inherit;
border-bottom: 1px solid var(--secondary);
}

.footer-version a:hover {
color: var(--primary);
border-bottom: 1px solid var(--primary);
}
113 changes: 113 additions & 0 deletions docs/gh-pages/assets/css/extended/highlightjs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Visual Studio 2015 dark style
* Author: Nicolas LLOBERA <[email protected]>
* Sourced from: https://github.com/highlightjs/highlight.js/blob/main/src/styles/vs2015.css
*/

.hljs {
background: #1E1E1E;
color: #DCDCDC;
}

.hljs-keyword,
.hljs-literal,
.hljs-symbol,
.hljs-name {
color: #569CD6;
}
.hljs-link {
color: #569CD6;
text-decoration: underline;
}

.hljs-built_in,
.hljs-type {
color: #4EC9B0;
}

.hljs-number,
.hljs-class {
color: #B8D7A3;
}

.hljs-string,
.hljs-meta .hljs-string {
color: #D69D85;
}

.hljs-regexp,
.hljs-template-tag {
color: #9A5334;
}

.hljs-subst,
.hljs-function,
.hljs-title,
.hljs-params,
.hljs-formula {
color: #DCDCDC;
}

.hljs-comment,
.hljs-quote {
color: #57A64A;
font-style: italic;
}

.hljs-doctag {
color: #608B4E;
}

.hljs-meta,
.hljs-meta .hljs-keyword,

.hljs-tag {
color: #9B9B9B;
}

.hljs-variable,
.hljs-template-variable {
color: #BD63C5;
}

.hljs-attr,
.hljs-attribute {
color: #9CDCFE;
}

.hljs-section {
color: gold;
}

.hljs-emphasis {
font-style: italic;
}

.hljs-strong {
font-weight: bold;
}

/*.hljs-code {
font-family:'Monospace';
}*/

.hljs-bullet,
.hljs-selector-tag,
.hljs-selector-id,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #D7BA7D;
}

.hljs-addition {
background-color: #144212;
display: inline-block;
width: 100%;
}

.hljs-deletion {
background-color: #600;
display: inline-block;
width: 100%;
}
Loading

0 comments on commit 7fd388a

Please sign in to comment.