Skip to content

Commit

Permalink
README install
Browse files Browse the repository at this point in the history
  • Loading branch information
wookay committed Aug 27, 2015
1 parent 81a238b commit 86b71cd
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 19 deletions.
124 changes: 124 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,127 @@ Linux, OSX: [![Build Status](https://api.travis-ci.org/wookay/PageDown.jl.svg?br
Windows: [![Build status](https://ci.appveyor.com/api/projects/status/61g3ch0ba6fafvmy?svg=true)](https://ci.appveyor.com/project/wookay/PageDown.jl)
[![Coverage Status](https://coveralls.io/repos/wookay/PageDown.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/wookay/PageDown.jl?branch=master)

# install
```shell
λ ~$ julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.4.0-dev+7032 (2015-08-27 04:01 UTC)
_/ |\__'_|_|_|\__'_| | Commit 5d3ccd6 (0 days old master)
|__/ | x86_64-apple-darwin14.5.0
julia> Pkg.clone("git@github.com:wookay/PageDown.jl.git")
INFO: Cloning PageDown from git@github.com:wookay/PageDown.jl.git
INFO: Computing changes...
julia> using PageDown
INFO: Recompiling stale cache file /Users/wookyoung/.julia/lib/v0.4/PageDown.ji for module PageDown.
```
# examples
```shell
julia> using PageDown
julia> using Base.Markdown
julia> pages = [
md"""
# hello
- 1
- 2
"""
md"""
# world
- 3
"""
md"""
# julia
- 123
"""
]
hello
≡≡≡≡≡≡≡
• 1
• 2
world
≡≡≡≡≡≡≡
• 3
julia
≡≡≡≡≡≡≡
• 123
julia> page = Page(pages)
PageDown.Page([Base.Markdown.MD(Any[Base.Markdown.Header{1}(Any["hello"]),Base.Markdown.List(Any[Any["1"],Any["2"]],false)],Dict{Any,Any}(:config=>Base.Markdown.Config([hashheader,fencedcode,blockquote],[blocktex,blockinterp,list,indentcode,github_table,horizontalrule,setextheader,paragraph],Dict('['=>[link],'\\'=>[linebreak,escapes],'*'=>[asterisk_bold,asterisk_italic],'$'=>[tex,interp],'`'=>[inline_code],'!'=>[image],'-'=>[en_dash])))),Base.Markdown.MD(Any[Base.Markdown.Header{1}(Any["world"]),Base.Markdown.List(Any[Any["3"]],false)],Dict{Any,Any}(:config=>Base.Markdown.Config([hashheader,fencedcode,blockquote],[blocktex,blockinterp,list,indentcode,github_table,horizontalrule,setextheader,paragraph],Dict('['=>[link],'\\'=>[linebreak,escapes],'*'=>[asterisk_bold,asterisk_italic],'$'=>[tex,interp],'`'=>[inline_code],'!'=>[image],'-'=>[en_dash])))),Base.Markdown.MD(Any[Base.Markdown.Header{1}(Any["julia"]),Base.Markdown.List(Any[Any["123"]],false)],Dict{Any,Any}(:config=>Base.Markdown.Config([hashheader,fencedcode,blockquote],[blocktex,blockinterp,list,indentcode,github_table,horizontalrule,setextheader,paragraph],Dict('['=>[link],'\\'=>[linebreak,escapes],'*'=>[asterisk_bold,asterisk_italic],'$'=>[tex,interp],'`'=>[inline_code],'!'=>[image],'-'=>[en_dash]))))],1,1,Dict{Any,Any}(),3)
julia> @current
hello
≡≡≡≡≡≡≡
• 1
• 2
julia> @page
1:1:3
julia> @next
world
≡≡≡≡≡≡≡
• 3
julia> @next
julia
≡≡≡≡≡≡≡
• 123
julia> @prev
world
≡≡≡≡≡≡≡
• 3
julia> @first
hello
≡≡≡≡≡≡≡
• 1
• 2
julia> @last
julia
≡≡≡≡≡≡≡
• 123
julia> @step 2
2
julia> @first
hello
≡≡≡≡≡≡≡
• 1
• 2
world
≡≡≡≡≡≡≡
• 3
julia> @next
julia
≡≡≡≡≡≡≡
• 123
```
15 changes: 8 additions & 7 deletions src/PageDown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ export @page, @current, @next, @prev, @go, @first, @last, @step, @open
__precompile__(true)

type Page
pages::AbstractArray
start::Int
step::Int
pages::Array
count::Int
option::Dict
Page(start, step, pages) = new(start, step, pages, length(pages), Dict())
Page(start, step, pages, option::Pair) = new(start, step, pages, length(pages), Dict(option))
Page(start, step, pages, option::Dict) = new(start, step, pages, length(pages), option)
count::Int
Page(pages::AbstractArray) = new(pages, 1, 1, Dict(), length(pages))
Page(pages::AbstractArray, start::Int, step::Int) = new(pages, start, step, Dict(), length(pages))
Page(pages::AbstractArray, start::Int, step::Int, option::Dict) = new(pages, start, step, option, length(pages))
Page(pages::AbstractArray, option::Pair...) = new(pages, 1, 1, Dict(option), length(pages))
end

function next!(page::Page)
if (page.start + page.step) < page.count
if (page.start + page.step) <= page.count
page.start += page.step
else
#println("last page")
Expand Down Expand Up @@ -61,7 +62,7 @@ function clear()
end

function proper(page::Page)
if page.start + page.step < page.count
if page.start + page.step <= page.count
slides = page.pages[page.start:page.start+page.step-1]
else
slides = page.pages[page.start:end]
Expand Down
6 changes: 1 addition & 5 deletions test/macro.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
module MacroTest

using Base.Test

push!(LOAD_PATH, "src")

using PageDown

pages = ["1", "2", "3", "4", "5"]
#page = Page(1, 1, pages)
page = Page(1, 1, pages, "IMG"=>"")
page = Page(pages)

@test (page.start:page.step:page.count) == @page
@test ["1"] == @current
Expand Down
7 changes: 2 additions & 5 deletions test/page.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
module PageTest

using Base.Test

push!(LOAD_PATH, "src")

using PageDown

pages = ["1", "2", "3", "4", "5"]
page = Page(1, 1, pages)
page = Page(pages)

@test 1 == page.start
@test 1 == page.step
Expand All @@ -31,7 +28,7 @@ first!(page)


# coverage
page = Page(1, 10, pages, Dict())
page = Page(pages, 1, 10)
@test_throws ArgumentError go!(page, 10)
last!(page)
@open 1
Expand Down
2 changes: 0 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
push!(LOAD_PATH, "src")

using PageDown

include("page.jl")
Expand Down

0 comments on commit 86b71cd

Please sign in to comment.