lib/*.log
lib/*.dot
+lib/*/bin
+
examples/*/doc
examples/*/bin
tags=example
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Action Nitro! an action platformer where you jump from plane to plane to reach the ISS and defeat the bad guys
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/action_nitro/
git=https://github.com/nitlang/nit.git
tags=example
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Sample portable 2D game implemented with the `simple_2d` API of gamnit
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/asteronits/
git=https://github.com/nitlang/nit.git
tags=mobile,web
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=An unofficial app and mailing list to keep faithful bargoers informed of the beers available at the excellent Brasserie Bénélux
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/benitlux/
git=https://github.com/nitlang/nit.git
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/brainfuck
+
+bin/brainfuck: $(shell $(NITLS) -M brainfuck.nit)
+ mkdir -p bin/
+ $(NITC) brainfuck.nit -o bin/brainfuck
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
First, compile the interpreter with the Nit compiler/interpreter, and launch the program on a brainfuck source file for interpretation.
Example:
-~~~
+~~~sh
nitc ./brainfuck.nit
./brainfuck ./examples/hello.bf
~~~
tags=language
maintainer=Lucas Bajolet <r4pass@hotmail.com>
license=Apache-2.0
+desc=Brainfuck, a simple Brainfuck interpreter written in Nit
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/brainfuck/
git=https://github.com/nitlang/nit.git
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/github_merge
+
+bin/github_merge: $(shell $(NITLS) -M github_merge.nit)
+ mkdir -p bin/
+ $(NITC) github_merge.nit -o bin/github_merge
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
import github::github_curl
import template
-import opts
+import config
redef class Object
# Factorize cast
var opt_keepgoing = new OptionBool("Skip merge conflicts", "-k", "--keep-going")
var opt_all = new OptionBool("Merge all", "-a", "--all")
var opt_status = new OptionArray("A status context that must be \"success\" (e.g. default)", "--status")
-var opts = new OptionContext
-opts.add_option(opt_repo, opt_auth, opt_query, opt_status, opt_all, opt_keepgoing)
-opts.parse(sys.args)
-var args = opts.rest
+var usage = new Buffer
+usage.append "Usage: github_merge [OPTION]... <PR number...>\n"
+usage.append "Query the Github PR API to perform a merge."
+
+var config = new Config
+config.tool_description = usage.write_to_string
+config.add_option(opt_repo, opt_auth, opt_query, opt_status, opt_all, opt_keepgoing)
+
+config.parse_options(sys.args)
+
+if config.opt_help.value then
+ config.usage
+ exit 0
+end
+
+var args = config.args
var auth = opt_auth.value or else ""
if auth == "" then auth = get_github_oauth
print "The merge is made"
mergemsg.write_to(stdout)
end
-
--- /dev/null
+# NAME
+
+github_merge - Query the Github PR API to perform a merge.
+
+# SYNOPSIS
+
+github_merge [OPTION]... <PR number...>
+
+# OPTIONS
+
+### `-h`, `-?`, `--help`
+Show this help message.
+
+### `-r`, `--repo`
+Repository (e.g. nitlang/nit).
+
+### `--auth`
+OAuth token.
+
+### `-q`, `--query`
+Query to get issues (e.g. label=ok_will_merge).
+
+### `--status`
+A status context that must be "success" (e.g. default).
+
+### `-a`, `--all`
+Merge all.
+
+### `-k`, `--keep-going`
+Skip merge conflicts.
\ No newline at end of file
tags=cli
maintainer=Jean Privat <jean@pryen.org>
license=Apache-2.0
+desc=Query the Github PR API to perform a merge
[upstream]
-browse=https://github.com/nitlang/nit/tree/master/contrib/github_merge.nit
+browse=https://github.com/nitlang/nit/tree/master/contrib/github_merge/
git=https://github.com/nitlang/nit.git
-git.directory=contrib/github_merge.nit
+git.directory=contrib/github_merge/
homepage=http://nitlanguage.org
issues=https://github.com/nitlang/nit/issues
-default:
- mkdir -p bin
- nitc -o bin/github_search_for_jni src/github_search_for_jni.nit
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/github_search_for_jni
+
+bin/github_search_for_jni: $(shell $(NITLS) -M src/github_search_for_jni.nit)
+ mkdir -p bin/
+ $(NITC) src/github_search_for_jni.nit -o bin/github_search_for_jni
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
tags=cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Seach Github for repositories possibly using the JNI
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/github_search_for_jni/
git=https://github.com/nitlang/nit.git
-bin/header_keeper:
- mkdir -p bin
- nitc --dir bin src/header_keeper.nit
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/header_keeper
+
+bin/header_keeper: $(shell $(NITLS) -M src/header_keeper.nit)
+ mkdir -p bin/
+ $(NITC) src/header_keeper.nit -o bin/header_keeper
+
+.PHONY: check
check: tests
+ $(NITUNIT) .
+
+.PHONY: tests
tests: bin/header_keeper
gcc -E /usr/include/SDL/SDL_image.h | bin/header_keeper SDL_image.h
gcc -E /usr/include/GLES2/gl2.h | bin/header_keeper gl2.h
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
tags=devel,cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Filter preprocessed C-like header files to remove included files
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/header_keeper/
git=https://github.com/nitlang/nit.git
-all:
- mkdir -p bin
- nitc --dir bin src/svg_to_png_and_nit.nit src/svg_to_icons.nit
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-.PHONY: bin/svg_to_png_and_nit
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/svg_to_icons bin/svg_to_png_and_nit
+
+bin/svg_to_icons: $(shell $(NITLS) -M src/svg_to_icons.nit)
+ mkdir -p bin/
+ $(NITC) src/svg_to_icons.nit -o bin/svg_to_icons
+
+bin/svg_to_png_and_nit: $(shell $(NITLS) -M src/svg_to_png_and_nit.nit)
+ mkdir -p bin/
+ $(NITC) src/svg_to_png_and_nit.nit -o bin/svg_to_png_and_nit
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
tags=devel,cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=tools to extract images from SVG files: `svg_to_icons` for app icons and `svg_to_png_and_nit` for game sprites
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/inkscape_tools/
git=https://github.com/nitlang/nit.git
tags=java,devel,cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Generator of Nit extern classes to wrap Java APIs
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/jwrapper/
git=https://github.com/nitlang/nit.git
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/memplot
+
+bin/memplot: $(shell $(NITLS) -M memplot.nit)
+ mkdir -p bin/
+ $(NITC) memplot.nit -o bin/memplot
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
tags=devel
maintainer=Jean Privat <jean@pryen.org>
license=Apache-2.0
+desc=Program to transform `memory.log` files produced by `nitc --trace-memory` into a csv file
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/memplot/
git=https://github.com/nitlang/nit.git
tags=example
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Sample portable 3D app implemented with the gamnit depth framework
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/model_viewer/
git=https://github.com/nitlang/nit.git
-git.directory=contrib/asteronits/
+git.directory=contrib/model_viewer/
homepage=http://nitlanguage.org
issues=https://github.com/nitlang/nit/issues
apk=http://nitlanguage.org/fdroid/apk/model_viewer.apk
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
-NITC=nitc
-NITC_FLAGS=--dir bin
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
NEO4J_DIR=/var/lib/neo4j
OLD_PWD=${PWD}
-.PHONY: bin reset-neo run-tests tests
+.PHONY: all
+all: bin/neo_doxygen
+
+bin/neo_doxygen: $(shell $(NITLS) -M src/neo_doxygen.nit)
+ mkdir -p bin/
+ $(NITC) src/neo_doxygen.nit -o bin/neo_doxygen
-# Compile the tool.
-bin:
- mkdir -p bin
- $(NITC) $(NITC_FLAGS) src/neo_doxygen.nit
+.PHONY: check
+check:
+ $(NITUNIT) .
# Reset the local graph.
+.PHONY: reset-neo
reset-neo:
sudo -u neo4j "${NEO4J_DIR}/bin/neo4j" stop \
- && sudo -u neo4j rm -rf "${NEO4J_DIR}/data/graph.db" \
- && sudo -u neo4j "${NEO4J_DIR}/bin/neo4j" start
+ && sudo -u neo4j rm -rf "${NEO4J_DIR}/data/graph.db" \
+ && sudo -u neo4j "${NEO4J_DIR}/bin/neo4j" start
# Regenerate the XML documents in `tests`.
+.PHONY: tests
tests:
$(MAKE) -C tests
# Run the tests.
+.PHONY: run-tests
run-tests:
cd ../../tests; \
- ./tests.sh ../contrib/neo_doxygen/src/tests/neo_doxygen_*.nit ; \
- cd "${OLD_PWD}"
+ ./tests.sh ../contrib/neo_doxygen/src/tests/neo_doxygen_*.nit ; \
+ cd "${OLD_PWD}"
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
tags=devel,cli
maintainer=Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
license=Apache-2.0
+desc=neo_doxygen, a tool to convert a Doxygen XML output into a Neo4j model
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/neo_doxygen/
git=https://github.com/nitlang/nit.git
tags=devel,cli
maintainer=Jean Privat <jean@pryen.org>
license=Apache-2.0
+desc=nitcc, a parser and lexer generator for Nit
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/nitcc/
git=https://github.com/nitlang/nit.git
-all:
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/nitester
+
+bin/nitester: $(shell $(NITLS) -M src/nitester.nit)
mkdir -p bin/
- nitc src/nitester.nit -o bin/nitester
+ $(NITC) src/nitester.nit -o bin/nitester
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
tags=devel,cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Tester of Nit engines on an MPI cluster
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/nitester/
git=https://github.com/nitlang/nit.git
-all:
- mkdir -p bin
- nitc --semi-global nitin.nit -m readline -o bin/nitin
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/nitin
+
+bin/nitin: $(shell $(NITLS) -M nitin.nit)
+ mkdir -p bin/
+ $(NITC) --semi-global nitin.nit -m readline -o bin/nitin
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
### Dynamic importation
-~~~
+~~~raw
-->print([0..10[.to_a.to_json)
1,20--26: Error: method `to_json` does not exists in `Array[Int]`.
print([0..10[.to_a.to_json)
tags=devel
maintainer=Jean Privat <jean@pryen.org>
license=GPL-3.0
+desc=An experimental Nit interactive interpreter
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/nitin/
git=https://github.com/nitlang/nit.git
-all: nitiwiki bin/nitiwiki_server
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-nitiwiki:
- mkdir -p bin
- nitc src/nitiwiki.nit -o bin/nitiwiki
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
-bin/nitiwiki_server: $(shell nitls -M src/wiki_edit.nit)
- nitc -o $@ src/wiki_edit.nit
+.PHONY: all
+all: bin/nitiwiki bin/wiki_edit
-check: nitiwiki
+bin/nitiwiki: $(shell $(NITLS) -M src/nitiwiki.nit)
+ mkdir -p bin/
+ $(NITC) src/nitiwiki.nit -o bin/nitiwiki
+
+bin/wiki_edit: $(shell $(NITLS) -M src/wiki_edit.nit)
+ mkdir -p bin/
+ $(NITC) src/wiki_edit.nit -o bin/wiki_edit
+
+.PHONY: check
+check: bin/nitiwiki
+ $(NITUNIT) .
cd tests; make
+.PHONY: doc
doc:
- nitdoc -d doc src/nitiwiki.nit
+ $(NITDOC) . -o doc/
+.PHONY: clean
clean:
- rm -rf bin
+ rm -rf bin/
+ rm -rf doc/
Basic wiki structure:
- root
- |- assets
- |- out
- |- pages
- |- templates
- | |- footer.html
- | |- header.html
- | |- menu.html
- | `- template.html
- `- config.ini
+~~~raw
+root
+|- assets
+|- out
+|- pages
+|- templates
+| |- footer.html
+| |- header.html
+| |- menu.html
+| `- template.html
+`- config.ini
+~~~
### pages
You can categorize your content in sections using sub-folders:
- pages
- |- section1
- | `- index.md
- |- section2
- | `- index.md
- |- page1.md
- |- page2.md
- `- index.md
+~~~raw
+pages
+|- section1
+| `- index.md
+|- section2
+| `- index.md
+|- page1.md
+|- page2.md
+`- index.md
+~~~
### assets
You can also use this directory to put some images or other files that will be
used in all your pages.
- assets
- |- css
- |- js
- `- logo.png
+~~~raw
+assets
+|- css
+|- js
+`- logo.png
+~~~
### templates
Just move to the directory where you want to store your source files and type:
- nitiwiki init
+~~~sh
+nitiwiki init
+~~~
This command will import the base structure of your wiki in the current directory.
At this point nitiwiki has created the main configuration file of your site:
Once you have done your changes, use:
- nitiwiki --status
+~~~sh
+nitiwiki --status
+~~~
This will show the impacts of your changes on the wiki structure.
Then type:
- nitiwiki --render
+~~~sh
+nitiwiki --render
+~~~
This will the generate the html output of your new content.
The option `--force` can be used to regenerate all the wiki.
The template file `template.html` represents the overall structure of your wiki pages.
- <!DOCTYPE html>
- <html>
- <head>
- <title>%TITLE%</title>
- <link href="%ROOT_URL%/assets/css/main.css" rel="stylesheet">
- </head>
- <body>
- %HEADER%
- %TOP_MENU%
- <div>
- %TRAIL%
- %BODY%
- %TRAIL%
- %FOOTER%
- </div>
- </body>
- </html>
+~~~html
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>%TITLE%</title>
+ <link href="%ROOT_URL%/assets/css/main.css" rel="stylesheet">
+ </head>
+ <body>
+ %HEADER%
+ %TOP_MENU%
+ <div>
+ %TRAIL%
+ %BODY%
+ %TRAIL%
+ %FOOTER%
+ </div>
+ </body>
+</html>
+~~~
Additionnal macros:
The template file `header.html` is generated on top of all the wiki pages.
- <header>
- <a href="#"><img src="%ROOT_URL%/%LOGO%" alt="logo"/></a>
- <h2>%SUBTITLE%</h2>
- <h1>%TITLE%</h1>
- </header>
+~~~html
+<header>
+ <a href="#"><img src="%ROOT_URL%/%LOGO%" alt="logo"/></a>
+ <h2>%SUBTITLE%</h2>
+ <h1>%TITLE%</h1>
+</header>
+~~~
### Footer template
The template file `footer.html` is generated on the bottom of all the wiki pages.
- <footer>
- <p>%TITLE% © %YEAR%</p>
- <p>last modification %GEN_TIME%</p>
- </footer>
+~~~html
+<footer>
+ <p>%TITLE% © %YEAR%</p>
+ <p>last modification %GEN_TIME%</p>
+</footer>
+~~~
Additionnal macros:
Its content can be static:
- <nav class="menu">
- <ul class="nav navbar-nav">
- <li><a href="#">Home</a></li>
- <li><a href="#">Page1</a></li>
- <li><a href="#">Page2</a></li>
- </ul>
- </nav>
+~~~html
+<nav class="menu">
+ <ul class="nav navbar-nav">
+ <li><a href="#">Home</a></li>
+ <li><a href="#">Page1</a></li>
+ <li><a href="#">Page2</a></li>
+ </ul>
+</nav>
+~~~
Or dynamic using the macro `MENUS`:
- <nav class="menu">
- <ul class="nav navbar-nav">
- %MENUS%
- </ul>
- </nav>
+~~~html
+<nav class="menu">
+ <ul class="nav navbar-nav">
+ %MENUS%
+ </ul>
+</nav>
+~~~
## Advanced usages
To automatically update your wiki when changes are pushed on the
origin repository you can use the following command in a git hook:
- nitiwiki --fetch --render
+~~~sh
+nitiwiki --fetch --render
+~~~
### Working with a remote server
Using the following command in your cron will update the web server instance
from git:
- nitiwiki --fetch --render --rsync
+~~~sh
+nitiwiki --fetch --render --rsync
+~~~
Be sure to set `wiki.rsync_dir` in order to correctly push your changes.
When using `--rsync`, keep in mind that the rendered output must be configured
--- /dev/null
+# NAME
+
+nitiwiki - A wiki engine based on markdown files and git.
+
+# SYNOPSIS
+
+nitiwiki [OPTION]...
+
+# OPTIONS
+
+### `-h`, `-?`, `--help`
+Show this help message.
+
+### `-v`
+Verbose level.
+
+### `-c`, `--config`
+Path to config.ini file.
+
+### `--init`
+Initialize a new wiki in the current directory.
+
+### `--status`
+Display wiki status.
+
+### `-r`, `--render`
+Render the out directory from markdown sources.
+
+### `-f`, `--force`
+Force render even if source files are unchanged.
+
+### `--clean`
+Clean the output directory.
+
+### `-s`, `--rsync`
+Synchronize outdir with distant wiki using rsync.
+
+### `--fetch`
+Render local source from git repo.
+
+### `--nit-dir`
+Nit base directory.
\ No newline at end of file
--- /dev/null
+# NAME
+
+wiki_edit - Web server to server generated files and modify the wiki from a web form.
+
+# SYNOPSIS
+
+wiki_edit [OPTION]...
+
+# OPTIONS
+
+### `-h`, `-?`, `--help`
+Show this help message.
+
+### `-c`, `--config`
+Path to config.ini file.
+
+### `--host`
+Host to bind the server to.
+
+### `--port`
+Port to bind the server to.
+
+### `--pass`
+Password file path.
\ No newline at end of file
tags=web,cli
maintainer=Alexandre Terrasa <alexandre@moz-code.org>
license=Apache-2.0
+desc=nitiwiki, a simple wiki manager based on markdown
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/nitiwiki/
git=https://github.com/nitlang/nit.git
import wiki_html
import markdown_highlight
+import config
# Locate nit directory
private fun compute_nit_dir(opt_nit_dir: OptionString): String do
return res.file_exists and "{res}/src/nit.nit".file_exists
end
-var opt_help = new OptionBool("Display this help message", "-h", "--help")
var opt_verbose = new OptionCount("Verbose level", "-v")
var opt_config = new OptionString("Path to config.ini file", "-c", "--config")
var opt_init = new OptionBool("Initialize a new wiki in the current directory", "--init")
var opt_fetch = new OptionBool("Render local source from git repo", "--fetch")
var opt_nit_dir = new OptionString("Nit base directory", "--nit-dir")
-var context = new OptionContext
-context.add_option(opt_help, opt_verbose, opt_config)
-context.add_option(opt_init, opt_status, opt_render, opt_force)
-context.add_option(opt_clean, opt_rsync, opt_fetch, opt_nit_dir)
-context.parse(args)
+var config = new Config
+config.add_option(opt_verbose, opt_config)
+config.add_option(opt_init, opt_status, opt_render, opt_force)
+config.add_option(opt_clean, opt_rsync, opt_fetch, opt_nit_dir)
-var config_filename = "config.ini"
+var usage = new Buffer
+usage.append "Usage: nitiwiki [OPTION]...\n"
+usage.append "A wiki engine based on markdown files and git."
+config.tool_description = usage.write_to_string
+
+config.parse_options(args)
-# --help
-if opt_help.value then
- context.usage
+if config.opt_help.value then
+ config.usage
exit 0
end
+var config_filename = "config.ini"
+
# --init
if opt_init.value then
if config_filename.file_exists then
exit 0
end
-var config = new WikiConfig(config_file)
-var wiki = new Nitiwiki(config)
+var wiki_config = new WikiConfig(config_file)
+var wiki = new Nitiwiki(wiki_config)
# --verbose
wiki.verbose_level = opt_verbose.value
module wiki_base
import template::macro
-import opts
import ini
# A Nitiwiki instance.
import nitcorn
import markdown
import md5
+import config
intrude import wiki_html
end
end
-var config_file_path = "config.ini"
-var iface = "localhost:8080"
-var password_file_path = "passwords"
+var opt_config = new OptionString("Path to config.ini file", "-c", "--config")
+var opt_host = new OptionString("Host to bind the server to", "--host")
+var opt_port = new OptionInt("Port to bind the server to", 8000, "--port")
+var opt_pass = new OptionString("Password file path", "--pass")
+
+var config = new Config
+config.add_option(opt_config, opt_host, opt_port, opt_pass)
+
+var usage = new Buffer
+usage.append "Usage: wiki_edit [OPTION]...\n"
+usage.append "Web server to server generated files and modify the wiki from a web form."
+config.tool_description = usage.write_to_string
+
+config.parse_options(args)
+
+if config.opt_help.value then
+ config.usage
+ exit 0
+end
+
+var config_file_path = opt_config.value or else "config.ini"
+var iface = "{opt_host.value or else "localhost"}:{opt_port.value}"
+var password_file_path = opt_pass.value or else "passwords"
# Load passwords for file
var passwords = if password_file_path.file_exists then
# This file is part of NIT ( http://www.nitlanguage.org ).
#
-# Copyright 2014-2015 Alexandre Terrasa <alexandre@moz-code.org>
-#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# See the License for the specific language governing permissions and
# limitations under the License.
-NITC=nitc
-NITU=nitunit
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
-all: listener web
+.PHONY: all
+all: bin/listener bin/web
-listener:
- $(NITC) src/listener.nit
+bin/listener: $(shell $(NITLS) -M src/listener.nit)
+ mkdir -p bin/
+ $(NITC) src/listener.nit -o bin/listener
-web:
- $(NITC) src/web.nit
+bin/web: $(shell $(NITLS) -M src/web.nit)
+ mkdir -p bin/
+ $(NITC) src/web.nit -o bin/web
+.PHONY: check
check:
- $(NITU) src/game.nit
- $(NITU) src/events.nit
- $(NITU) src/statistics.nit
- $(NITU) src/achievements.nit
- $(NITU) src/listener.nit
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+.PHONY: clean
clean:
- rm listener web
+ rm -rf bin/
+ rm -rf doc/
tags=devel,web,cli
maintainer=Alexandre Terrasa <alexandre@moz-code.org>
license=Apache-2.0
+desc=NitRPG, a Role Playing Game that takes place on GitHub
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/nitrpg/
git=https://github.com/nitlang/nit.git
tags=devel,cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Generator of Nit extern classes to wrap Objective-C services
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/objcwrapper/
git=https://github.com/nitlang/nit.git
tags=web
maintainer=Lucas Bajolet <r4pass@hotmail.com>
license=Apache-2.0
+desc=Opportunity is a web-application written in Nit to plan meetups with people in real-life (or on the internet, why not !)
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/opportunity/
git=https://github.com/nitlang/nit.git
tags=educ,web,cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Pep/8 Analysis, a static checker to detect bugs and bad programming practices in Pep/8 programs
[source]
exclude=src/parser/parser_abs.nit
[upstream]
tags=embedded,cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Backend to a hardware interface to control an MPD server from a Raspberry Pi
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/physical_interface_for_mpd_on_rpi/
git=https://github.com/nitlang/nit.git
tags=re
maintainer=Alexandre Terrasa <alexandre@moz-code.org>
license=Apache-2.0
+desc=RE Parser, a simple API for regular expression parsing
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/re_parser/
git=https://github.com/nitlang/nit.git
# This file is part of NIT ( http://www.nitlanguage.org ).
#
-# Copyright 2015 Alexandre Terrasa <alexandre@moz-code.org>
-#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# See the License for the specific language governing permissions and
# limitations under the License.
-all: refund
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/refund
-refund:
- mkdir -p bin
- nitc src/refund.nit -o bin/refund
+bin/refund: $(shell $(NITLS) -M src/refund.nit)
+ mkdir -p bin/
+ $(NITC) src/refund.nit -o bin/refund
-check: refund
+.PHONY: check
+check: bin/refund
+ $(NITUNIT) .
cd tests; make
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
clean:
- rm -rf bin
+ rm -rf bin/
+ rm -rf doc/
cd tests; make clean
tags=example,cli
maintainer=Alexandre Terrasa <alexandre@moz-code.org>
license=Apache-2.0
+desc=Insurance refunds calculation tool
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/refund/
git=https://github.com/nitlang/nit.git
-all:
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/rss_downloader
+
+bin/rss_downloader: $(shell $(NITLS) -M src/rss_downloader.nit)
mkdir -p bin/
- nitc --dir bin/ src/*.nit
+ $(NITC) src/rss_downloader.nit -o bin/rss_downloader
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
tags=network,cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=A tool to download files listed in RSS feeds according to local folders
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/rss_downloader/
git=https://github.com/nitlang/nit.git
tags=web
maintainer=Jean Privat <jean@pryen.org>
license=Apache-2.0
+desc=Gather the authenticated users on UQAM websites
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/shibuqam/
git=https://github.com/nitlang/nit.git
tags=ai,example,cli
maintainer=Jean Privat <jean@pryen.org>
license=Apache-2.0
+desc=A simple planning problem solver using A* for a robot that delivers parcels
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/simplan/
git=https://github.com/nitlang/nit.git
-build:
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/sort_downloads
+
+bin/sort_downloads: $(shell $(NITLS) -M src/sort_downloads.nit)
mkdir -p bin/
- nitc --dir bin/ src/*.nit
+ $(NITC) src/sort_downloads.nit -o bin/sort_downloads
+.PHONY: install
install:
install bin/sort_downloads /usr/local/bin/
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
If you need more than one configuration, let's say to sort videos, you can use Nit class refinement. Create a separate Nit module next to `src/sort_downloads.nit` named `sort_videos.nit` and use something like:
- #!/usr/bin/env nit
+~~~nitish
+#!/usr/bin/env nit
- import sort_downloads
+import sort_downloads
- redef class Config
- redef fun source_dir do return "/media/new-drive/video-downloads"
- redef fun dest_dir do return "/media/new-drive/Videos"
- redef fun regex_source_dirs do return ["~/Videos", dest_dir]
- redef fun elapsed_days do return 0
- end
+redef class Config
+ redef fun source_dir do return "/media/new-drive/video-downloads"
+ redef fun dest_dir do return "/media/new-drive/Videos"
+ redef fun regex_source_dirs do return ["~/Videos", dest_dir]
+ redef fun elapsed_days do return 0
+end
- super # this executes the program
+super # this executes the program
+~~~
## Sort only older files
tags=cli
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Script to sort content of a folder in many folders according to their names
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/sort_downloads/
git=https://github.com/nitlang/nit.git
tags=game
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Tinks! a multiplayer crossplatform action game with destructible procedurally generated worlds
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/tinks/
git=https://github.com/nitlang/nit.git
tags=web,mobile
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Tnitter, a Twitter-like micro-blogging platform
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/tnitter/
git=https://github.com/nitlang/nit.git
# See the License for the specific language governing permissions and
# limitations under the License.
-module wiringPi is example
+module shift is example
import wiringPi
tags=embedded,wrapper
maintainer=Alexandre Terrasa <alexandre@moz-code.org>
license=Apache-2.0
+desc=wiringPi nit wrapper
[upstream]
browse=https://github.com/nitlang/nit/tree/master/contrib/wiringPi/
git=https://github.com/nitlang/nit.git
tags=web,example
maintainer=Alexis Laferrière <alexis.laf@xymus.net>
license=Apache-2.0
+desc=Web server source and config of xymus.net
[upstream]
-browse=https://github.com/nitlang/nit/tree/master/contrib/xymus.net/
+browse=https://github.com/nitlang/nit/tree/master/contrib/xymus_net/
git=https://github.com/nitlang/nit.git
-git.directory=contrib/xymus.net/
+git.directory=contrib/xymus_net/
homepage=http://xymus.net/
issues=https://github.com/nitlang/nit/issues
--- /dev/null
+# This file is part of NIT (http://www.nitlanguage.org).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module test_a_star is test
+
+import a_star
+
+class TestAStar
+ test
+
+ # Graph
+ # ~~~raw
+ # a - b
+ # / /
+ # c - d - e
+ # ~~~
+ fun case_simple is test do
+ var graph = new Graph[NamedNode, Link]
+
+ var na = new NamedNode(graph, "a")
+ var nb = new NamedNode(graph, "b")
+ var nc = new NamedNode(graph, "c")
+ var nd = new NamedNode(graph, "d")
+ var ne = new NamedNode(graph, "e")
+
+ var lab = new Link(graph, na, nb)
+ var lac = new Link(graph, na, nc)
+ var lbd = new Link(graph, nb, nd)
+ var lcd = new Link(graph, nc, nd)
+ var lde = new Link(graph, nd, ne)
+
+ var context = new ConstantPathContext(graph)
+
+ var path = na.path_to(ne, 100, context)
+ assert path_to_string(path) == "c, d, e"
+ end
+
+ # Graph
+ # ~~~raw
+ # a - b
+ # / /
+ # c - d e
+ # ~~~
+ fun case_failed is test do
+ var graph = new Graph[NamedNode,Link]
+
+ var na = new NamedNode(graph, "a")
+ var nb = new NamedNode(graph, "b")
+ var nc = new NamedNode(graph, "c")
+ var nd = new NamedNode(graph, "d")
+ var ne = new NamedNode(graph, "e")
+
+ var lab = new Link(graph, na, nb)
+ var lac = new Link(graph, na, nc)
+ var lbd = new Link(graph, nb, nd)
+ var lcd = new Link(graph, nc, nd)
+
+ var context = new ConstantPathContext(graph)
+
+ var path = na.path_to(ne, 100, context)
+ assert path_to_string(path) == null
+ end
+
+ # Weighted graph
+ # ~~~raw
+ # a -2- b
+ # / /
+ # 3 1
+ # / /
+ # c -3- d -8- e
+ # ~~~
+ fun case_weighted is test do
+ var graph = new Graph[NamedNode,WeightedLink]
+
+ var na = new NamedNode(graph, "a")
+ var nb = new NamedNode(graph, "b")
+ var nc = new NamedNode(graph, "c")
+ var nd = new NamedNode(graph, "d")
+ var ne = new NamedNode(graph, "e")
+
+ var lab = new WeightedLink(graph, na, nb, 2)
+ var lac = new WeightedLink(graph, na, nc, 3)
+ var lbd = new WeightedLink(graph, nb, nd, 1)
+ var lcd = new WeightedLink(graph, nc, nd, 3)
+ var lde = new WeightedLink(graph, nd, ne, 8)
+
+ var context = new WeightedPathContext(graph)
+
+ var path = na.path_to(ne, 100, context)
+ assert path_to_string(path) == "b, d, e"
+ end
+
+ # Weighted graph
+ # ~~~raw
+ # a -2- b
+ # / /
+ # 3 1
+ # / /
+ # c -3- d -8- e
+ # ~~~
+ fun case_weighted_too_long is test do
+ var graph = new Graph[NamedNode,WeightedLink]
+
+ var na = new NamedNode(graph, "a")
+ var nb = new NamedNode(graph, "b")
+ var nc = new NamedNode(graph, "c")
+ var nd = new NamedNode(graph, "d")
+ var ne = new NamedNode(graph, "e")
+
+ var lab = new WeightedLink(graph, na, nb, 2)
+ var lac = new WeightedLink(graph, na, nc, 3)
+ var lbd = new WeightedLink(graph, nb, nd, 1)
+ var lcd = new WeightedLink(graph, nc, nd, 3)
+ var lde = new WeightedLink(graph, nd, ne, 8)
+
+ var context = new WeightedPathContext(graph)
+
+ var path = na.path_to(ne, 5, context)
+ assert path_to_string(path) == null
+ end
+
+ # "Big" weighted graph
+ # ~~~raw
+ #
+ # a -2- b -1- f -1- g
+ # / / \ /
+ # 3 1 4 1
+ # / / \ /
+ # c -3- d -8- e -2- h -2- i -3- j
+ # ~~~
+ fun case_weighted_big is test do
+ var graph = new Graph[NamedNode,WeightedLink]
+
+ var na = new NamedNode(graph, "a")
+ var nb = new NamedNode(graph, "b")
+ var nc = new NamedNode(graph, "c")
+ var nd = new NamedNode(graph, "d")
+ var ne = new NamedNode(graph, "e")
+ var nf = new NamedNode(graph, "f")
+ var ng = new NamedNode(graph, "g")
+ var nh = new NamedNode(graph, "h")
+ var ni = new NamedNode(graph, "i")
+ var nj = new NamedNode(graph, "j")
+
+ var lab = new WeightedLink(graph, na, nb, 2)
+ var lac = new WeightedLink(graph, na, nc, 3)
+ var lbd = new WeightedLink(graph, nb, nd, 1)
+ var lcd = new WeightedLink(graph, nc, nd, 3)
+ var lde = new WeightedLink(graph, nd, ne, 8)
+ var lbf = new WeightedLink(graph, nb, nf, 1)
+ var lfg = new WeightedLink(graph, nf, ng, 1)
+ var leh = new WeightedLink(graph, ne, nh, 2)
+ var lhi = new WeightedLink(graph, nh, ni, 2)
+ var lij = new WeightedLink(graph, ni, nj, 3)
+ var lfh = new WeightedLink(graph, nf, nh, 4)
+ var lgh = new WeightedLink(graph, ng, nh, 1)
+
+ var context = new WeightedPathContext(graph)
+
+ var path = na.path_to(nj, 100, context)
+ assert path_to_string(path) == "b, f, g, h, i, j"
+ end
+
+ # Double-edge graph with coordinates on nodes
+ #
+ # ~~~raw
+ # a--b--d--e
+ # \ |
+ # c------f
+ # ~~~
+ fun cases_with_positions_and_heuristic is test do
+ var graph = new Graph[PositionedNamedNode,PositionedLink]
+
+ var na = new PositionedNamedNode(graph, "a", 0, 0)
+ var nb = new PositionedNamedNode(graph, "b", 2, 0)
+ var nc = new PositionedNamedNode(graph, "c", 2, 2)
+ var nd = new PositionedNamedNode(graph, "d", 5, 0)
+ var ne = new PositionedNamedNode(graph, "e", 8, 0)
+ var nf = new PositionedNamedNode(graph, "f", 8, 2)
+
+ var lab = new PositionedLink(graph, na, nb)
+ var lac = new PositionedLink(graph, na, nc)
+ var lbd = new PositionedLink(graph, nb, nd)
+ var lde = new PositionedLink(graph, nd, ne)
+ var lef = new PositionedLink(graph, ne, nf)
+ var lcf = new PositionedLink(graph, nc, nf)
+
+ # inverted
+ var lba = new PositionedLink(graph, nb, na)
+ var lca = new PositionedLink(graph, nc, na)
+ var ldb = new PositionedLink(graph, nd, nb)
+ var led = new PositionedLink(graph, ne, nd)
+ var lfe = new PositionedLink(graph, nf, ne)
+ var lfc = new PositionedLink(graph, nf, nc)
+
+ var context = new PositionPathContext(graph)
+
+ assert path_to_string(na.path_to(nf, 100, context)) == "c, f"
+ assert path_to_string(nf.path_to(na, 100, context)) == "c, a"
+ assert path_to_string(nc.path_to(ne, 100, context)) == "f, e"
+ assert path_to_string(nd.path_to(nc, 100, context)) == "b, a, c"
+ end
+
+ fun path_to_string(path: nullable AStarPath[NamedNode]): nullable String do
+ if path == null then
+ return null
+ else
+ var names = new Array[String]
+ while not path.at_end_of_path do
+ var step = path.step
+ names.add(step.name)
+ end
+ return names.join(", ")
+ end
+ end
+end
+
+#redef class Object
+# redef fun debug_a_star do return true
+#end
+
+# Simple node with a name
+class NamedNode
+ super Node
+
+ redef type N: NamedNode
+
+ var name: String
+
+ redef fun to_s do return "node:{name}"
+end
+
+# Node with a name and position
+class PositionedNamedNode
+ super NamedNode
+
+ redef type N: PositionedNamedNode
+
+ var x: Int
+ var y: Int
+
+ redef fun to_s do return "{super}-at-({x},{y})"
+
+ fun dist_with(o: PositionedNamedNode): Int
+ do
+ var dx = o.x - x
+ var dy = o.y - y
+ var d2 = dx*dx + dy*dy
+ return d2.sqrt
+ end
+end
+
+# Link for nodes with a position
+class PositionedLink
+ super Link
+
+ redef type N: PositionedNamedNode
+end
+
+# Context for a graph with positions
+class PositionPathContext
+ super PathContext
+
+ redef type N: PositionedNamedNode
+ redef type L: PositionedLink
+
+ init do
+ super
+
+ for l in graph.links do
+ var this_cost = cost(l)
+ if this_cost > worst_cost then worst_cost = this_cost
+ end
+ end
+
+ redef var worst_cost = 0
+
+ redef fun cost(link) do return link.from.dist_with(link.to)
+
+ redef fun is_blocked(link) do return false
+
+ redef fun heuristic_cost(a, b)
+ do
+ var cost = a.dist_with(b)
+ if cost > 100 then return 100
+ return cost
+ end
+
+ redef fun worst_heuristic_cost do return 100
+end
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module test_base64 is test
+
+import base64
+
+class TestBase64
+ test
+
+ fun test_encode is test do
+ assert "".encode_base64 == ""
+ assert "f".encode_base64 == "Zg=="
+ assert "fo".encode_base64 == "Zm8="
+ assert "foo".encode_base64 == "Zm9v"
+ assert "foob".encode_base64 == "Zm9vYg=="
+ assert "fooba".encode_base64 == "Zm9vYmE="
+ assert "foobar".encode_base64 == "Zm9vYmFy"
+ end
+
+ fun test_decode is test do
+ assert "".decode_base64.to_s == ""
+ assert "Zg==".decode_base64.to_s == "f"
+ assert "Zm8=".decode_base64.to_s == "fo"
+ assert "Zm9v".decode_base64.to_s == "foo"
+ assert "Zm9vYg==".decode_base64.to_s == "foob"
+ assert "Zm9vYmE=".decode_base64.to_s == "fooba"
+ assert "Zm9vYmFy".decode_base64.to_s == "foobar"
+
+ assert "Zm9vYg".decode_base64.to_s == "foob"
+ assert "Zm9vYmE".decode_base64.to_s == "fooba"
+ assert "Zm9v*Yg".decode_base64.to_s == "foob"
+ end
+
+ fun test_is_base64 is test do
+ assert "Znm=".is_base64
+ assert not "Znm===".is_base64
+ assert not "Z.sd=".is_base64
+ assert not "Z==D".is_base64
+ end
+
+ fun test_check_base64 is test do
+ assert "Znm=".check_base64 == null
+ assert "Znm===".check_base64.as(not null).to_s == "Invalid padding length"
+ assert "Z.sd=".check_base64.as(not null).to_s == "Invalid Base64 character at position 1: ."
+ assert "Z==D".check_base64.as(not null).to_s == "Invalid padding character D at position 3"
+ end
+end
redef fun write_to(stream) do stream.write(self)
end
-# Input streams with a buffered input for efficiency purposes
-abstract class BufferedReader
- super Reader
-
- redef fun raw_read_byte
- do
- if last_error != null then return -1
- if eof then
- last_error = new IOError("Stream has reached eof")
- return -1
- end
- var c = _buffer[_buffer_pos]
- _buffer_pos += 1
- return c.to_i
- end
-
- # Resets the internal buffer
- fun buffer_reset do
- _buffer_length = 0
- _buffer_pos = 0
- end
-
- # Peeks up to `n` bytes in the buffer
- #
- # The operation does not consume the buffer
- #
- # ~~~nitish
- # var x = new FileReader.open("File.txt")
- # assert x.peek(5) == x.read(5)
- # ~~~
- fun peek(i: Int): Bytes do
- if eof then return new Bytes.empty
- var remsp = _buffer_length - _buffer_pos
- if i <= remsp then
- var bf = new Bytes.with_capacity(i)
- bf.append_ns_from(_buffer, i, _buffer_pos)
- return bf
- end
- var bf = new Bytes.with_capacity(i)
- bf.append_ns_from(_buffer, remsp, _buffer_pos)
- _buffer_pos = _buffer_length
- read_intern(i - bf.length, bf)
- remsp = _buffer_length - _buffer_pos
- var full_len = bf.length + remsp
- if full_len > _buffer_capacity then
- var c = _buffer_capacity
- while c < full_len do c = c * 2 + 2
- _buffer_capacity = c
- end
- var nns = new CString(_buffer_capacity)
- bf.items.copy_to(nns, bf.length, 0, 0)
- _buffer.copy_to(nns, remsp, _buffer_pos, bf.length)
- _buffer = nns
- _buffer_pos = 0
- _buffer_length = full_len
- return bf
- end
-
- redef fun read_bytes_to_cstring(buf, i)
- do
- if last_error != null then return 0
- var bbf = new Bytes(buf, 0, i)
- return read_intern(i, bbf)
- end
-
- # Fills `buf` with at most `i` bytes read from `self`
- private fun read_intern(i: Int, buf: Bytes): Int do
- if eof then return 0
- var p = _buffer_pos
- var bufsp = _buffer_length - p
- if bufsp >= i then
- _buffer_pos += i
- buf.append_ns_from(_buffer, i, p)
- return i
- end
- _buffer_pos = _buffer_length
- var readln = _buffer_length - p
- buf.append_ns_from(_buffer, readln, p)
- var rd = read_intern(i - readln, buf)
- return rd + readln
- end
-
- redef fun read_all_bytes
- do
- if last_error != null then return new Bytes.empty
- var s = new Bytes.with_capacity(10)
- var b = _buffer
- while not eof do
- var j = _buffer_pos
- var k = _buffer_length
- var rd_sz = k - j
- s.append_ns_from(b, rd_sz, j)
- _buffer_pos = k
- fill_buffer
- end
- return s
- end
-
- redef fun append_line_to(s)
- do
- var lb = new Bytes.with_capacity(10)
- loop
- # First phase: look for a '\n'
- var i = _buffer_pos
- while i < _buffer_length and _buffer[i] != 0xAu8 do
- i += 1
- end
-
- var eol
- if i < _buffer_length then
- assert _buffer[i] == 0xAu8
- i += 1
- eol = true
- else
- eol = false
- end
-
- # if there is something to append
- if i > _buffer_pos then
- # Copy from the buffer to the string
- var j = _buffer_pos
- while j < i do
- lb.add(_buffer[j])
- j += 1
- end
- _buffer_pos = i
- else
- assert end_reached
- s.append lb.to_s
- return
- end
-
- if eol then
- # so \n is found
- s.append lb.to_s
- return
- else
- # so \n is not found
- if end_reached then
- s.append lb.to_s
- return
- end
- fill_buffer
- end
- end
- end
-
- redef fun eof
- do
- if _buffer_pos < _buffer_length then return false
- if end_reached then return true
- fill_buffer
- return _buffer_pos >= _buffer_length and end_reached
- end
-
- # The buffer
- private var buffer: CString = new CString(0)
-
- # The current position in the buffer
- private var buffer_pos = 0
-
- # Length of the current buffer (i.e. nuber of bytes in the buffer)
- private var buffer_length = 0
-
- # Capacity of the buffer
- private var buffer_capacity = 0
-
- # Fill the buffer
- protected fun fill_buffer is abstract
-
- # Has the last fill_buffer reached the end
- protected fun end_reached: Bool is abstract
-
- # Allocate a `_buffer` for a given `capacity`.
- protected fun prepare_buffer(capacity: Int)
- do
- _buffer = new CString(capacity)
- _buffer_pos = 0 # need to read
- _buffer_length = 0
- _buffer_capacity = capacity
- end
-end
-
# A `Stream` that can be written to and read from
abstract class Duplex
super Reader
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
+
+.PHONY: all
+all: bin/loader
+
+bin/loader: $(shell $(NITLS) -M loader.nit)
+ mkdir -p bin/
+ $(NITC) loader.nit -o bin/loader
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
--- /dev/null
+# NAME
+
+loader - Load a GitHub repo into a MongoDb.
+
+# SYNOPSIS
+
+loader <repo_name>
+
+# OPTIONS
+
+### `-h`, `-?`, `--help`
+Show this help message.
+
+### `--config`
+Path to config file.
+
+### `--db-host`
+MongoDb host.
+
+### `--db-name`
+MongoDb database name.
+
+### `--tokens`
+Token list.
+
+### `--show-wallet`
+Show wallet status.
+
+### `-v`, `--verbose`
+Verbosity level.
+
+### `--no-colors`
+Do not use colors in output.
+
+### `--show-jobs`
+Show jobs status.
+
+### `--no-commits`
+Do not load commits from default branch.
+
+### `--no-issues`
+Do not load issues.
+
+### `--no-comments`
+Do not load issue comments.
+
+### `--no-events`
+Do not load issues events.
+
+### `--from`
+Start loading issues from a number.
+
+### `--clear`
+Clear job for given repo name.
\ No newline at end of file
-NITC=nitc
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-all: nitmd
+NITC ?= nitc
+NITLS ?= nitls
+NITUNIT ?= nitunit
+NITDOC ?= nitdoc
-nitmd: nitmd.nit
- ${NITC} $<
+.PHONY: all
+all: bin/nitmd
+
+bin/nitmd: $(shell $(NITLS) -M nitmd.nit)
+ mkdir -p bin/
+ $(NITC) nitmd.nit -o bin/nitmd
+
+.PHONY: check
+check:
+ $(NITUNIT) .
+
+.PHONY: doc
+doc:
+ $(NITDOC) . -o doc/
+
+.PHONY: clean
+clean:
+ rm -rf bin/
+ rm -rf doc/
--- /dev/null
+# NAME
+
+nitmd - Translate Markdown documents to other formats.
+
+# SYNOPSIS
+
+nitmd [-t format] <file.md>
+
+# OPTIONS
+
+### `-h`, `-?`, `--help`
+Show this help message.
+
+### `-t`, `--to`
+Specify output format (html, md, man).
OUT=$(patsubst %.md,man1/%.1,$(IN))
MARKDOWN=../../lib/markdown
-NITMD=$(MARKDOWN)/nitmd
+NITMD=$(MARKDOWN)/bin/nitmd
all: $(OUT)
### `--check-ini`
Check package.ini files.
+### `--gen-makefile`
+Generate Makefile files.
+
+### `--check-makefile`
+Check Makefile files.
+
+### `--check-man`
+Check manpages files.
+
+### `--gen-man`
+Generate manpages files.
+
### `-f`, `--force`
Force update of existing files.
intrude import doc::commands::commands_main
import doc::commands::commands_md
-class TestCommandsHtml
+class TestCommandsMd
super TestCommands
test
module nitpackage
import frontend
+import doc::commands::commands_main
redef class ToolContext
# --expand
# --force
var opt_force = new OptionBool("Force update of existing files", "-f", "--force")
- # README handling phase
- var readme_phase: Phase = new ReadmePhase(self, null)
+ # --check-makefile
+ var opt_check_makefile = new OptionBool("Check Makefile files", "--check-makefile")
+
+ # --gen-makefile
+ var opt_gen_makefile = new OptionBool("Generate Makefile files", "--gen-makefile")
+
+ # nitpackage phase
+ var nitpackage_phase: Phase = new NitPackagePhase(self, null)
+
+ # --check-man
+ var opt_check_man = new OptionBool("Check manpages files", "--check-man")
+
+ # --gen-man
+ var opt_gen_man = new OptionBool("Generate manpages files", "--gen-man")
redef init do
super
option_context.add_option(opt_expand, opt_force)
option_context.add_option(opt_check_ini, opt_gen_ini)
+ option_context.add_option(opt_check_makefile, opt_gen_makefile)
+ option_context.add_option(opt_check_man, opt_gen_man)
end
end
-private class ReadmePhase
+private class NitPackagePhase
super Phase
redef fun process_mainmodule(mainmodule, mmodules) do
continue
end
+ # Check package Makefiles
+ if toolcontext.opt_check_makefile.value then
+ mpackage.check_makefile(toolcontext, mainmodule)
+ continue
+ end
+
+ # Check manpages
+ if toolcontext.opt_check_man.value then
+ mpackage.check_man(toolcontext, mainmodule)
+ continue
+ end
+
# Expand packages
if toolcontext.opt_expand.value and not mpackage.is_expanded then
var path = mpackage.expand
toolcontext.info("generated INI file `{path}`", 0)
end
end
+
+ # Create Makefile
+ if toolcontext.opt_gen_makefile.value then
+ if not mpackage.has_makefile or toolcontext.opt_force.value then
+ var path = mpackage.gen_makefile(toolcontext.modelbuilder.model, mainmodule)
+ if path != null then
+ toolcontext.info("generated Makefile `{path}`", 0)
+ end
+ end
+ end
+
+ # Create manpages
+ if toolcontext.opt_gen_man.value then
+ mpackage.gen_man(toolcontext, mainmodule)
+ end
end
end
"package.name", "package.desc", "package.tags", "package.license",
"package.maintainer", "package.more_contributors",
"upstream.browse", "upstream.git", "upstream.git.directory",
- "upstream.homepage", "upstream.issues"
+ "upstream.homepage", "upstream.issues", "upstream.apk", "upstream.tryit",
+ "source.exclude"
]
private fun check_ini(toolcontext: ToolContext) do
ini.save
return ini_path
end
+
+ # Makefile
+
+ # The path to `self` Makefile
+ fun makefile_path: nullable String do
+ var path = package_path
+ if path == null then return null
+ if not is_expanded then return null
+ return path / "Makefile"
+ end
+
+ # Does `self` have a Makefile?
+ fun has_makefile: Bool do
+ var makefile_path = self.makefile_path
+ if makefile_path == null then return false
+ return makefile_path.file_exists
+ end
+
+ private fun check_makefile(toolcontext: ToolContext, mainmodule: MModule) do
+ var model = toolcontext.modelbuilder.model
+ var filter = new ModelFilter(accept_example = false, accept_test = false)
+ var view = new ModelView(model, mainmodule, filter)
+
+ var cmd_bin = new CmdMains(view, mentity = self)
+ var res_bin = cmd_bin.init_command
+ if not res_bin isa CmdSuccess then return
+
+ for mmodule in cmd_bin.results.as(not null) do
+ if not mmodule isa MModule then continue
+
+ if mmodule.makefile_path == null then
+ toolcontext.warning(location, "missing-makefile",
+ "Warning: no Makefile for executable module `{mmodule.full_name}`")
+ end
+ end
+ end
+
+ private fun gen_makefile(model: Model, mainmodule: MModule): nullable String do
+ var filter = new ModelFilter(accept_example = false, accept_test = false)
+ var view = new ModelView(model, mainmodule, filter)
+
+ var pkg_path = package_path.as(not null)
+ var makefile_path = makefile_path.as(not null)
+
+ var bins = new Array[String]
+ var cmd_bin = new CmdMains(view, mentity = self)
+ var res_bin = cmd_bin.init_command
+ if res_bin isa CmdSuccess then
+ for mmodule in cmd_bin.results.as(not null) do
+ if not mmodule isa MModule then continue
+ var mmodule_makefile = mmodule.makefile_path
+ if mmodule_makefile != null and mmodule_makefile != makefile_path then continue
+
+ var file = mmodule.location.file
+ if file == null then continue
+ # Remove package path prefix
+ var bin_path = file.filename
+ if pkg_path.has_suffix("/") then
+ bin_path = bin_path.replace(pkg_path, "")
+ else
+ bin_path = bin_path.replace("{pkg_path}/", "")
+ end
+ bins.add bin_path
+ end
+ end
+
+ if bins.is_empty then return null
+
+ var make = new NitMakefile(bins)
+ make.render.write_to_file(makefile_path)
+ return makefile_path
+ end
+
+ # Manpages
+
+ # The path to `self` manpage files
+ private fun man_path: nullable String do
+ var path = package_path
+ if path == null then return null
+ if not is_expanded then return null
+ return path / "man"
+ end
+
+ # Does `self` have a manpage files?
+ private fun has_man: Bool do
+ var man_path = self.man_path
+ if man_path == null then return false
+ return man_path.file_exists
+ end
+
+ private fun check_man(toolcontext: ToolContext, mainmodule: MModule) do
+ var model = toolcontext.modelbuilder.model
+ var filter = new ModelFilter(accept_example = false, accept_test = false)
+ var view = new ModelView(model, mainmodule, filter)
+
+ var cmd = new CmdMains(view, mentity = self)
+ var res = cmd.init_command
+ if not res isa CmdSuccess then return
+
+ for mmodule in cmd.results.as(not null) do
+ if not mmodule isa MModule then continue
+ mmodule.check_man(toolcontext)
+ end
+ end
+
+ private fun gen_man(toolcontext: ToolContext, mainmodule: MModule) do
+ var model = toolcontext.modelbuilder.model
+ var filter = new ModelFilter(accept_example = false, accept_test = false)
+ var view = new ModelView(model, mainmodule, filter)
+
+ var cmd = new CmdMains(view, mentity = self)
+ var res = cmd.init_command
+ if not res isa CmdSuccess then return
+
+ var pkg_man = man_path.as(not null)
+ for mmodule in cmd.results.as(not null) do
+ if not mmodule isa MModule then continue
+ if not has_man then pkg_man.mkdir
+ mmodule.gen_man(toolcontext)
+ end
+ end
+end
+
+redef class MModule
+ private fun makefile_path: nullable String do
+ var file = location.file
+ if file == null then return null
+
+ var dir = file.filename.dirname
+ var makefile = (dir / "Makefile")
+ if not makefile.file_exists then return null
+
+ for line in makefile.to_path.read_lines do
+ if line.has_prefix("{name}:") then return makefile
+ end
+ return null
+ end
+
+ private fun man_path: nullable String do
+ var mpackage = self.mpackage
+ if mpackage == null then return null
+ var path = mpackage.man_path
+ if path == null then return null
+ return path / "{name}.man"
+ end
+
+ # Does `self` have a manpage?
+ private fun has_man: Bool do
+ var man_path = self.man_path
+ if man_path == null then return false
+ return man_path.file_exists
+ end
+
+ private fun make_module(toolcontext: ToolContext): Bool do
+ var mpackage = self.mpackage
+ if mpackage == null then return false
+ if not mpackage.is_expanded then return false
+
+ var pkg_path = mpackage.package_path
+ if pkg_path == null then return false
+
+ var pr = new ProcessReader("sh", "-c", "cd {pkg_path} && make -Bs bin/{name}")
+ var out = pr.read_all.trim
+ pr.close
+ pr.wait
+ if pr.status > 0 then
+ toolcontext.error(location, "unable to compile `{name}`")
+ print out
+ return false
+ end
+ return true
+ end
+
+ private fun stub_man(toolcontext: ToolContext): nullable String do
+ if not make_module(toolcontext) then return null
+ var mpackage = self.mpackage
+ if mpackage == null then return null
+ if not mpackage.is_expanded then return null
+
+ var pkg_path = mpackage.package_path
+ if pkg_path == null then return null
+
+ var pr = new ProcessReader("{pkg_path}/bin/{name}", "--stub-man")
+ var man = pr.read_all.trim
+ pr.close
+ pr.wait
+ if pr.status > 0 then
+ toolcontext.error(location, "unable to run `{pkg_path}/bin/{name} --stub-man`")
+ print man
+ return null
+ end
+ return man
+ end
+
+ private fun check_man(toolcontext: ToolContext) do
+ if not has_man then
+ toolcontext.error(location, "No manpage for bin {full_name}")
+ return
+ end
+ var man_path = self.man_path.as(not null)
+ var man = stub_man(toolcontext)
+ if man == null or man.is_empty then return
+
+ var old_man = new ManPage.from_file(self, man_path)
+ var new_man = new ManPage.from_string(self, man)
+ old_man.diff(toolcontext, new_man)
+ end
+
+ private fun gen_man(toolcontext: ToolContext) do
+ var man = stub_man(toolcontext)
+ if man == null or man.is_empty then return
+ var man_path = self.man_path
+ if man_path == null then return
+ man.write_to_file(man_path)
+ toolcontext.info("created manpage `{man_path}`", 0)
+ end
end
redef class ConfigTree
end
end
+# A Makefile for the Nit project
+class NitMakefile
+
+ # Nit files to compile
+ var nit_files: Array[String]
+
+ # List of rules to add in the Makefile
+ fun rules: Array[MakeRule] do
+ var rules = new Array[MakeRule]
+
+ var rule_all = new MakeRule("all", is_phony = true)
+ rules.add rule_all
+
+ for file in nit_files do
+ var bin = file.basename.strip_extension
+
+ rule_all.deps.add "bin/{bin}"
+
+ var rule = new MakeRule("bin/{bin}")
+ rule.deps.add "$(shell $(NITLS) -M {file})"
+ rule.lines.add "mkdir -p bin/"
+ rule.lines.add "$(NITC) {file} -o bin/{bin}"
+ rules.add rule
+ end
+
+ var rule_check = new MakeRule("check", is_phony = true)
+ rule_check.lines.add "$(NITUNIT) ."
+ rules.add rule_check
+
+ var rule_doc = new MakeRule("doc", is_phony = true)
+ rule_doc.lines.add "$(NITDOC) . -o doc/"
+ rules.add rule_doc
+
+ var rule_clean = new MakeRule("clean", is_phony = true)
+ if nit_files.not_empty then
+ rule_clean.lines.add "rm -rf bin/"
+ end
+ rule_clean.lines.add "rm -rf doc/"
+ rules.add rule_clean
+
+ return rules
+ end
+
+ # Render `self`
+ fun render: Writable do
+ var tpl = new Template
+ tpl.addn """
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.\n"""
+
+ if nit_files.not_empty then
+ tpl.addn "NITC ?= nitc"
+ tpl.addn "NITLS ?= nitls"
+ end
+ tpl.addn "NITUNIT ?= nitunit"
+ tpl.addn "NITDOC ?= nitdoc"
+
+ for rule in rules do
+ tpl.add "\n{rule.render.write_to_string}"
+ end
+
+ return tpl
+ end
+end
+
+# A rule that goes into a Makefile
+class MakeRule
+
+ # Rule name
+ var name: String
+
+ # Is this rule a `.PHONY` one?
+ var is_phony: Bool = false is optional
+
+ # Rule dependencies
+ var deps = new Array[String]
+
+ # Rule lines
+ var lines = new Array[String]
+
+ # Render `self`
+ fun render: Writable do
+ var tpl = new Template
+ if is_phony then
+ tpl.addn ".PHONY: {name}"
+ end
+ tpl.add "{name}:"
+ if deps.not_empty then
+ tpl.add " {deps.join(" ")}"
+ end
+ tpl.add "\n"
+ for line in lines do
+ tpl.addn "\t{line}"
+ end
+ return tpl
+ end
+end
+
+private class ManPage
+ var mmodule: MModule
+ var name: nullable String is noinit
+ var synopsis: nullable String is noinit
+ var options = new HashMap[Array[String], String]
+
+ init from_file(mmodule: MModule, file: String) do
+ from_lines(mmodule, file.to_path.read_lines)
+ end
+
+ init from_string(mmodule: MModule, string: String) do
+ from_lines(mmodule, string.split("\n"))
+ end
+
+ init from_lines(mmodule: MModule, lines: Array[String]) do
+ init mmodule
+
+ var section = null
+ for i in [0..lines.length[ do
+ var line = lines[i]
+ if line.is_empty then continue
+
+ if line == "# NAME" then
+ section = "name"
+ continue
+ end
+ if line == "# SYNOPSIS" then
+ section = "synopsis"
+ continue
+ end
+ if line == "# OPTIONS" then
+ section = "options"
+ continue
+ end
+
+ if section == "name" and name == null then
+ name = line.trim
+ end
+ if section == "synopsis" and synopsis == null then
+ synopsis = line.trim
+ end
+ if section == "options" and line.has_prefix("###") then
+ var opts = new Array[String]
+ for opt in line.substring(3, line.length).trim.replace("`", "").split(",") do
+ opts.add opt.trim
+ end
+ var desc = ""
+ if i < lines.length - 1 then
+ desc = lines[i + 1].trim
+ end
+ options[opts] = desc
+ end
+ end
+ end
+
+ fun diff(toolcontext: ToolContext, ref: ManPage) do
+ if name != ref.name then
+ toolcontext.warning(mmodule.location, "diff-man",
+ "Warning: outdated man description. " +
+ "Expected `{ref.name or else ""}` got `{name or else ""}`.")
+ end
+ if synopsis != ref.synopsis then
+ toolcontext.warning(mmodule.location, "diff-man",
+ "Warning: outdated man synopsis. " +
+ "Expected `{ref.synopsis or else ""}` got `{synopsis or else ""}`.")
+ end
+ for name, desc in options do
+ if not ref.options.has_key(name) then
+ toolcontext.warning(mmodule.location, "diff-man",
+ "Warning: unknown man option `{name}`.`")
+ continue
+ end
+ var ref_desc = ref.options[name]
+ if desc != ref_desc then
+ toolcontext.warning(mmodule.location, "diff-man",
+ "Warning: outdated man option description. Expected `{ref_desc}` got `{desc}`.")
+ end
+ end
+ for ref_name, ref_desc in ref.options do
+ if not options.has_key(ref_name) then
+ toolcontext.warning(mmodule.location, "diff-man",
+ "Warning: missing man option `{ref_name}`.`")
+ end
+ end
+ end
+
+ redef fun to_s do
+ var tpl = new Template
+ tpl.addn "# NAME"
+ tpl.addn name or else ""
+ tpl.addn "# SYNOPSIS"
+ tpl.addn synopsis or else ""
+ tpl.addn "# OPTIONS"
+ for name, desc in options do
+ tpl.addn " * {name}: {desc}"
+ end
+ return tpl.write_to_string
+ end
+end
+
# build toolcontext
var toolcontext = new ToolContext
var tpl = new Template
tags=devel,cli
maintainer=Jean Privat <jean@pryen.org>
license=Apache-2.0
+desc=Nit compiler and tools
[source]
exclude=parser/parser_abs.nit:parser/.parser-nofact.nit
[upstream]
-browse=https://github.com/nitlang/nit/tree/master/src
+browse=https://github.com/nitlang/nit/tree/master/src/
git=https://github.com/nitlang/nit.git
-git.directory=src
+git.directory=src/
homepage=http://nitlanguage.org
issues=https://github.com/nitlang/nit/issues
+++ /dev/null
-c, d, e
-null path
-b, d, e
-null path
-b, f, g, h, i, j
-c, f
-c, a
-f, e
-b, a, c
+++ /dev/null
-:
-f: Zg==
-fo: Zm8=
-foo: Zm9v
-foob: Zm9vYg==
-fooba: Zm9vYmE=
-foobar: Zm9vYmFy
-:
-Zg==: f
-Zm8=: fo
-Zm9v: foo
-Zm9vYg==: foob
-Zm9vYmE=: fooba
-Zm9vYmFy: foobar
-Zm9vYg: foob
-Zm9vYmE: fooba
-Zm9v*Yg: foob
-:
-Znm=.is_base64? true
-Znm===.is_base64? false
-Z.sd=.is_base64? false
-Z==D.is_base64? false
-:
-Znm=: No error
-Znm===: Invalid padding length
-Z.sd=: Invalid Base64 character at position 1: .
-Z==D: Invalid padding character D at position 3
+++ /dev/null
-module test_a_star
-
-import a_star
-
-#redef class Object
-# redef fun debug_a_star do return true
-#end
-
-# Simple node with a name
-class NamedNode
- super Node
-
- redef type N: NamedNode
-
- var name: String
-
- init(graph: Graph[N, Link], name: String)
- do
- self.name = name
- super
- end
-
- redef fun to_s do return "node:{name}"
-end
-
-# Node with a name and position
-class PositionedNamedNode
- super NamedNode
-
- redef type N: PositionedNamedNode
-
- var x: Int
- var y: Int
-
- init(graph: Graph[N, Link], name: String, x, y: Int)
- do
- super
-
- self.x = x
- self.y = y
- end
-
- redef fun to_s do return "{super}-at-({x},{y})"
-
- fun dist_with(o: PositionedNamedNode): Int
- do
- var dx = o.x - x
- var dy = o.y - y
- var d2 = dx*dx + dy*dy
- return d2.sqrt
- end
-end
-
-# Link for nodes with a position
-class PositionedLink
- super Link
-
- redef type N: PositionedNamedNode
-end
-
-# Context for a graph with positions
-class PositionPathContext
- super PathContext
-
- redef type N: PositionedNamedNode
- redef type L: PositionedLink
-
- init(graph: Graph[N,L])
- do
- super
-
- for l in graph.links do
- var this_cost = cost(l)
- if this_cost > worst_cost then worst_cost = this_cost
- end
- end
-
- redef var worst_cost = 0
-
- redef fun cost(link) do return link.from.dist_with(link.to)
-
- redef fun is_blocked(link) do return false
-
- redef fun heuristic_cost(a, b)
- do
- var cost = a.dist_with(b)
- if cost > 100 then return 100
- return cost
- end
-
- redef fun worst_heuristic_cost do return 100
-end
-
-fun print_path(path: nullable AStarPath[NamedNode]) do if path == null then
- print "null path"
-else
- var names = new Array[String]
- while not path.at_end_of_path do
- var step = path.step
- names.add(step.name)
- end
- print names.join(", ")
-end
-
-# Graph
-# a - b
-# / /
-# c - d - e
-fun case_simple
-do
- var graph = new Graph[NamedNode, Link]
-
- var na = new NamedNode(graph, "a")
- var nb = new NamedNode(graph, "b")
- var nc = new NamedNode(graph, "c")
- var nd = new NamedNode(graph, "d")
- var ne = new NamedNode(graph, "e")
-
- var lab = new Link(graph, na, nb)
- var lac = new Link(graph, na, nc)
- var lbd = new Link(graph, nb, nd)
- var lcd = new Link(graph, nc, nd)
- var lde = new Link(graph, nd, ne)
-
- var context = new ConstantPathContext(graph)
-
- var path = na.path_to(ne, 100, context)
- print_path(path)
-end
-
-# Graph
-# a - b
-# / /
-# c - d e
-fun case_failed
-do
- var graph = new Graph[NamedNode,Link]
-
- var na = new NamedNode(graph, "a")
- var nb = new NamedNode(graph, "b")
- var nc = new NamedNode(graph, "c")
- var nd = new NamedNode(graph, "d")
- var ne = new NamedNode(graph, "e")
-
- var lab = new Link(graph, na, nb)
- var lac = new Link(graph, na, nc)
- var lbd = new Link(graph, nb, nd)
- var lcd = new Link(graph, nc, nd)
-
- var context = new ConstantPathContext(graph)
-
- var path = na.path_to(ne, 100, context)
- print_path(path)
-end
-
-# Weighted graph
-# a -2- b
-# / /
-# 3 1
-# / /
-# c -3- d -8- e
-fun case_weighted
-do
- var graph = new Graph[NamedNode,WeightedLink]
-
- var na = new NamedNode(graph, "a")
- var nb = new NamedNode(graph, "b")
- var nc = new NamedNode(graph, "c")
- var nd = new NamedNode(graph, "d")
- var ne = new NamedNode(graph, "e")
-
- var lab = new WeightedLink(graph, na, nb, 2)
- var lac = new WeightedLink(graph, na, nc, 3)
- var lbd = new WeightedLink(graph, nb, nd, 1)
- var lcd = new WeightedLink(graph, nc, nd, 3)
- var lde = new WeightedLink(graph, nd, ne, 8)
-
- var context = new WeightedPathContext(graph)
-
- var path = na.path_to(ne, 100, context)
- print_path(path)
-end
-
-# Weighted graph
-# a -2- b
-# / /
-# 3 1
-# / /
-# c -3- d -8- e
-fun case_weighted_too_long
-do
- var graph = new Graph[NamedNode,WeightedLink]
-
- var na = new NamedNode(graph, "a")
- var nb = new NamedNode(graph, "b")
- var nc = new NamedNode(graph, "c")
- var nd = new NamedNode(graph, "d")
- var ne = new NamedNode(graph, "e")
-
- var lab = new WeightedLink(graph, na, nb, 2)
- var lac = new WeightedLink(graph, na, nc, 3)
- var lbd = new WeightedLink(graph, nb, nd, 1)
- var lcd = new WeightedLink(graph, nc, nd, 3)
- var lde = new WeightedLink(graph, nd, ne, 8)
-
- var context = new WeightedPathContext(graph)
-
- var path = na.path_to(ne, 5, context)
- print_path(path)
-end
-
-# "Big" weighted graph
-#
-# a -2- b -1- f -1- g
-# / / \ /
-# 3 1 4 1
-# / / \ /
-# c -3- d -8- e -2- h -2- i -3- j
-#
-fun case_weighted_big
-do
- var graph = new Graph[NamedNode,WeightedLink]
-
- var na = new NamedNode(graph, "a")
- var nb = new NamedNode(graph, "b")
- var nc = new NamedNode(graph, "c")
- var nd = new NamedNode(graph, "d")
- var ne = new NamedNode(graph, "e")
- var nf = new NamedNode(graph, "f")
- var ng = new NamedNode(graph, "g")
- var nh = new NamedNode(graph, "h")
- var ni = new NamedNode(graph, "i")
- var nj = new NamedNode(graph, "j")
-
- var lab = new WeightedLink(graph, na, nb, 2)
- var lac = new WeightedLink(graph, na, nc, 3)
- var lbd = new WeightedLink(graph, nb, nd, 1)
- var lcd = new WeightedLink(graph, nc, nd, 3)
- var lde = new WeightedLink(graph, nd, ne, 8)
- var lbf = new WeightedLink(graph, nb, nf, 1)
- var lfg = new WeightedLink(graph, nf, ng, 1)
- var leh = new WeightedLink(graph, ne, nh, 2)
- var lhi = new WeightedLink(graph, nh, ni, 2)
- var lij = new WeightedLink(graph, ni, nj, 3)
- var lfh = new WeightedLink(graph, nf, nh, 4)
- var lgh = new WeightedLink(graph, ng, nh, 1)
-
- var context = new WeightedPathContext(graph)
-
- var path = na.path_to(nj, 100, context)
- print_path(path)
-end
-
-# Double-edge graph with coordinates on nodes
-#
-# a--b--d--e
-# \ |
-# c------f
-#
-fun cases_with_positions_and_heuristic
-do
- var graph = new Graph[PositionedNamedNode,PositionedLink]
-
- var na = new PositionedNamedNode(graph, "a", 0, 0)
- var nb = new PositionedNamedNode(graph, "b", 2, 0)
- var nc = new PositionedNamedNode(graph, "c", 2, 2)
- var nd = new PositionedNamedNode(graph, "d", 5, 0)
- var ne = new PositionedNamedNode(graph, "e", 8, 0)
- var nf = new PositionedNamedNode(graph, "f", 8, 2)
-
- var lab = new PositionedLink(graph, na, nb)
- var lac = new PositionedLink(graph, na, nc)
- var lbd = new PositionedLink(graph, nb, nd)
- var lde = new PositionedLink(graph, nd, ne)
- var lef = new PositionedLink(graph, ne, nf)
- var lcf = new PositionedLink(graph, nc, nf)
-
- # inverted
- var lba = new PositionedLink(graph, nb, na)
- var lca = new PositionedLink(graph, nc, na)
- var ldb = new PositionedLink(graph, nd, nb)
- var led = new PositionedLink(graph, ne, nd)
- var lfe = new PositionedLink(graph, nf, ne)
- var lfc = new PositionedLink(graph, nf, nc)
-
- var context = new PositionPathContext(graph)
-
- print_path(na.path_to(nf, 100, context))
- print_path(nf.path_to(na, 100, context))
- print_path(nc.path_to(ne, 100, context))
- print_path(nd.path_to(nc, 100, context))
-end
-
-case_simple
-case_failed
-case_weighted
-case_weighted_too_long
-case_weighted_big
-cases_with_positions_and_heuristic
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2013 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import base64
-
-print ":" + "".encode_base64
-print "f: " + "f".encode_base64
-print "fo: " + "fo".encode_base64
-print "foo: " + "foo".encode_base64
-print "foob: " + "foob".encode_base64
-print "fooba: " + "fooba".encode_base64
-print "foobar: " + "foobar".encode_base64
-
-print ":" + "".decode_base64.to_s
-print "Zg==: " + "Zg==".decode_base64.to_s
-print "Zm8=: " + "Zm8=".decode_base64.to_s
-print "Zm9v: " + "Zm9v".decode_base64.to_s
-print "Zm9vYg==: " + "Zm9vYg==".decode_base64.to_s
-print "Zm9vYmE=: " + "Zm9vYmE=".decode_base64.to_s
-print "Zm9vYmFy: " + "Zm9vYmFy".decode_base64.to_s
-
-print "Zm9vYg: " + "Zm9vYg".decode_base64.to_s
-print "Zm9vYmE: " + "Zm9vYmE".decode_base64.to_s
-print "Zm9v*Yg: " + "Zm9v*Yg".decode_base64.to_s
-
-print ":"
-print "Znm=.is_base64? " + "Znm=".is_base64.to_s
-print "Znm===.is_base64? " + "Znm===".is_base64.to_s
-print "Z.sd=.is_base64? " + "Z.sd=".is_base64.to_s
-print "Z==D.is_base64? " + "Z==D".is_base64.to_s
-
-print ":"
-printn "Znm=: "
-print "Znm=".check_base64 or else "No error"
-printn "Znm===: "
-print "Znm===".check_base64 or else "No error"
-printn "Z.sd=: "
-print "Z.sd=".check_base64 or else "No error"
-printn "Z==D: "
-print "Z==D".check_base64 or else "No error"