Skip to content

Commit

Permalink
doc: array: fix typo package->Package, update building script from go…
Browse files Browse the repository at this point in the history
…tmpl, support go-deps.txt to install dependency that are not in go.mod; support literal include when building README in jinja2 template format
  • Loading branch information
drmingdrmer committed Nov 23, 2020
1 parent e8f33e6 commit 8dfe7c6
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 16 deletions.
25 changes: 19 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,24 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: test
run: go test ./...
- name: Check go-deps.txt existence
id: check_deps
uses: andstor/file-existence-action@v1
with:
files: "go-deps.txt"

- name: test examples iplist
run: cd example/iplist && go run iplist.go
- name: Read go-deps.txt
id: godeps
if: steps.check_deps.outputs.files_exists == 'true'
uses: juliangruber/read-file-action@v1
with:
path: ./go-deps.txt

- name: test examples slimstar
run: cd example/slimstar && go run slimstar.go
- name: Install go-deps.txt
if: steps.check_deps.outputs.files_exists == 'true'
run: |
go get ${{ steps.godeps.outputs.content }}
- name: test
run: |
go test ./...
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# slimarray

[![Travis](https://travis-ci.com/openacid/slimarray.svg?branch=main)](https://travis-ci.com/openacid/slimarray)
<!-- [![AppVeyor](https://ci.appveyor.com/api/projects/status/m0vvvrru7a1g4mae/branch/main?svg=true)](https://ci.appveyor.com/project/drmingdrmer/slimarray/branch/main) -->
![test](https://github.com/openacid/slimarray/workflows/test/badge.svg)

[![Report card](https://goreportcard.com/badge/github.com/openacid/slimarray)](https://goreportcard.com/report/github.com/openacid/slimarray)
[![Coverage Status](https://coveralls.io/repos/github/openacid/slimarray/badge.svg?branch=main&service=github)](https://coveralls.io/github/openacid/slimarray?branch=main&service=github)

[![GoDoc](https://godoc.org/github.com/openacid/slimarray?status.svg)](http://godoc.org/github.com/openacid/slimarray)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/openacid/slimarray)](https://pkg.go.dev/github.com/openacid/slimarray)
[![Sourcegraph](https://sourcegraph.com/github.com/openacid/slimarray/-/badge.svg)](https://sourcegraph.com/github.com/openacid/slimarray?badge)

SlimArray is a space efficient, static `uint32` array.
Expand Down Expand Up @@ -151,7 +151,7 @@ func ExampleSlimArray() {

# How it works

package slimarray uses polynomial to compress and store an array of uint32. A
Package slimarray uses polynomial to compress and store an array of uint32. A
uint32 costs only 5 bits in a sorted array of a million number in range [0,
1000*1000].

Expand Down
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ doc:
godocdown . > docs/$(NAME).md
# "package" is the first phrase in a go doc.
# "## Usage" is the start of API section.
cat docs/$(NAME).md | awk '/^package /,/^## Usage/' | grep -v '^## Usage' > docs/$(NAME)-package.md
cat docs/$(NAME).md | awk '/^Package /,/^## Usage/' | grep -v '^## Usage' > docs/$(NAME)-package.md


readme: doc
Expand Down
2 changes: 1 addition & 1 deletion docs/badges.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[![Travis](https://travis-ci.com/openacid/{{ name }}.svg?branch=main)](https://travis-ci.com/openacid/{{ name }})
<!-- [![AppVeyor](https://ci.appveyor.com/api/projects/status/m0vvvrru7a1g4mae/branch/main?svg=true)](https://ci.appveyor.com/project/drmingdrmer/{{ name }}/branch/main) -->
![test](https://github.com/openacid/{{ name }}/workflows/test/badge.svg)

[![Report card](https://goreportcard.com/badge/github.com/openacid/{{ name }})](https://goreportcard.com/report/github.com/openacid/{{ name }})
[![Coverage Status](https://coveralls.io/repos/github/openacid/{{ name }}/badge.svg?branch=main&service=github)](https://coveralls.io/github/openacid/{{ name }}?branch=main&service=github)

[![GoDoc](https://godoc.org/github.com/openacid/{{ name }}?status.svg)](http://godoc.org/github.com/openacid/{{ name }})
[![PkgGoDev](https://pkg.go.dev/badge/github.com/openacid/{{ name }})](https://pkg.go.dev/github.com/openacid/{{ name }})
[![Sourcegraph](https://sourcegraph.com/github.com/openacid/{{ name }}/-/badge.svg)](https://sourcegraph.com/github.com/openacid/{{ name }}?badge)
2 changes: 1 addition & 1 deletion docs/slimarray-package.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package slimarray uses polynomial to compress and store an array of uint32. A
Package slimarray uses polynomial to compress and store an array of uint32. A
uint32 costs only 5 bits in a sorted array of a million number in range [0,
1000*1000].

Expand Down
2 changes: 1 addition & 1 deletion docs/slimarray.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--
import "github.com/openacid/slimarray"

package slimarray uses polynomial to compress and store an array of uint32. A
Package slimarray uses polynomial to compress and store an array of uint32. A
uint32 costs only 5 bits in a sorted array of a million number in range [0,
1000*1000].

Expand Down
11 changes: 8 additions & 3 deletions scripts/build_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
import subprocess

def render_j2(tmpl_path, tmpl_vars, output_path):
template_loader = jinja2.FileSystemLoader(searchpath='./')
template_env = jinja2.Environment(loader=template_loader,

def include_file(name):
return jinja2.Markup(loader.get_source(env, name)[0])

loader = jinja2.FileSystemLoader(searchpath='./')
env = jinja2.Environment(loader=loader,
undefined=jinja2.StrictUndefined)
template = template_env.get_template(tmpl_path)
env.globals['include_file'] = include_file
template = env.get_template(tmpl_path)

txt = template.render(tmpl_vars)

Expand Down
2 changes: 1 addition & 1 deletion slimarray.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// package slimarray uses polynomial to compress and store an array of uint32.
// Package slimarray uses polynomial to compress and store an array of uint32.
// A uint32 costs only 5 bits in a sorted array of a million number in range [0,
// 1000*1000].
//
Expand Down

0 comments on commit 8dfe7c6

Please sign in to comment.