Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Nov 13, 2024
1 parent c16afee commit 4031b98
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions docs/api/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ pagy_extras :array, :metadata, ...

### then you can use it like inside an app
pagy, items = pagy_array((1..1000).to_a, page: 3)
=> [#<Pagy:0x00007f59d9cd7190 @count=1000, @from=41, @in=20, @last=50, @limit=20, @next=4, @offset=40, @outset=0, @page=3, @prev=2, @to=60, @vars={:count_args=>[:all], :ends=>true, :limit=>20, :outset=>0, :page=>3, :page_param=>:page, :size=>7, :url=>"http://www.example.com/subdir", :metadata=>[:scaffold_url, :first_url, :prev_url, :page_url, :next_url, :last_url, :count, :page, :limit, :vars, :pages, :last, :in, :from, :to, :prev, :next, :series], :count=>1000}>, [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]

pagy_nav(pagy)
=> [#<Pagy:0x00007fdff0234880 @count=1000, @from=41, @in=20, @limit=20, @last=50, @next=4, @offset=40, @outset=0, @page=3, @prev=2, @to=60, @vars={:page=>3, :limit=>20, :outset=>0, :size=>7, :cycle=>false, :count_args=>[:all], :page_param=>:page, :url=>"http://www.example.com/subdir", :count=>1000}>, [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]
=> "<nav class=\"pagy nav\" aria-label=\"Pages\"><a href=\"http://www.example.com/subdir?page=2\" aria-label=\"Previous\">&lt;</a><a href=\"http://www.example.com/subdir?page=1\">1</a><a href=\"http://www.example.com/subdir?page=2\">2</a><a role=\"link\" aria-disabled=\"true\" aria-current=\"page\" class=\"current\">3</a><a href=\"http://www.example.com/subdir?page=4\">4</a><a href=\"http://www.example.com/subdir?page=5\">5</a><a href=\"http://www.example.com/subdir?page=6\">6</a><a href=\"http://www.example.com/subdir?page=7\">7</a><a href=\"http://www.example.com/subdir?page=4\" aria-label=\"Next\">&gt;</a></nav>"
=> "<nav class=\"pagy nav\" aria-label=\"Pages\"><a href=\"http://www.example.com/subdir?page=2\" aria-label=\"Previous\">&lt;</a><a href=\"http://www.example.com/subdir?page=1\">1</a><a href=\"http://www.example.com/subdir?page=2\">2</a><a role=\"link\" aria-disabled=\"true\" aria-current=\"page\" class=\"current\">3</a><a href=\"http://www.example.com/subdir?page=4\">4</a><a href=\"http://www.example.com/subdir?page=5\">5</a><a role=\"link\" aria-disabled=\"true\" class=\"gap\">&hellip;</a><a href=\"http://www.example.com/subdir?page=50\">50</a><a href=\"http://www.example.com/subdir?page=4\" aria-label=\"Next\">&gt;</a></nav>"

pagy_metadata(pagy)pagy_metadata(pagy)
pagy_metadata(pagy)
=>
{ :scaffold_url => "http://www.example.com/subdir?page=__pagy_page__",
:first_url => "http://www.example.com/subdir?page=1",
Expand Down
1 change: 1 addition & 0 deletions docs/extras/standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ method, the `:params` variable and the `:page` param to it.
==- Dummy `params` method

This extra creates a dummy `params` method (if not already defined) in the module where you include the `Pagy::Backend` (usually a controller). The method is called by pagy to fetch the backend variables coming from the request, and expects a hash, so the dummy param method returns an empty hash avoiding an error.

===
6 changes: 3 additions & 3 deletions tasks/test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

require 'rake/testtask'

# Almost each test recreates a different environment,
# Almost each test recreates a different environment
# and must run in a separate process in order to avoid
# to override other tests so we create one task per test.
# to override other tests, so we create one task per test.
# That's a bit slow but consistent and easier when developing.

# Use the :test task to run them all

# Get the full list of of all the test tasks (and test files that each task run) with:
# Get the full list of all the test tasks (and test files that each task run) with:
# rake -D test_*

names = []
Expand Down

0 comments on commit 4031b98

Please sign in to comment.