Skip to content

Commit 6568330

Browse files
committed
docs: add linked tables of contents to the guide pages
- Every guide page gets a "Contents:" block of anchor links after the intro, and ai-reference's existing list is now clickable - Also added to the two long internal pages; skipped the README, the docs index, changelog/upgrade notes, and the generated behavior matrix Based on Lucia's doc-review branch, regenerated against current headings.
1 parent 81f14cb commit 6568330

11 files changed

Lines changed: 111 additions & 18 deletions

docs/ai-reference.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ links here are absolute).
1616

1717
Contents:
1818

19-
- What is SmartArray
20-
- Class Hierarchy and Type Hints
21-
- Creating Collections
22-
- Reading and Writing Fields
23-
- Missing Keys and SmartNull
24-
- Iteration and Keys
25-
- Mode Conversion and Plain Arrays
26-
- Single Elements - first(), last(), at()
27-
- Collection Checks - count(), isEmpty(), isNotEmpty(), contains()
28-
- Row Position - isFirst(), isLast(), position()
29-
- Filtering and Sorting - where(), whereNot(), whereInList(), filter(), sort(), sortBy(), unique()
30-
- Transforming and Grouping - column(), columnAt(), indexBy(), groupBy(), keys(), values(), map(), merge(), implode()
31-
- Guards - or404(), orDie(), orThrow(), orRedirect()
32-
- Database Metadata - mysqli(), load()
33-
- Debugging - debug()
34-
- Errors and Exceptions
35-
- Deprecated Names
36-
- Gotchas Quick Reference
19+
- [What is SmartArray](#what-is-smartarray)
20+
- [Class Hierarchy and Type Hints](#class-hierarchy-and-type-hints)
21+
- [Creating Collections](#creating-collections)
22+
- [Reading and Writing Fields](#reading-and-writing-fields)
23+
- [Missing Keys and SmartNull](#missing-keys-and-smartnull)
24+
- [Iteration and Keys](#iteration-and-keys)
25+
- [Mode Conversion and Plain Arrays](#mode-conversion-and-plain-arrays)
26+
- [Single Elements](#single-elements) - first(), last(), at()
27+
- [Collection Checks](#collection-checks) - count(), isEmpty(), isNotEmpty(), contains()
28+
- [Row Position](#row-position) - isFirst(), isLast(), position()
29+
- [Filtering and Sorting](#filtering-and-sorting) - where(), whereNot(), whereInList(), filter(), sort(), sortBy(), unique()
30+
- [Transforming and Grouping](#transforming-and-grouping) - column(), columnAt(), indexBy(), groupBy(), keys(), values(), map(), merge(), implode()
31+
- [Guards](#guards) - or404(), orDie(), orThrow(), orRedirect()
32+
- [Database Metadata](#database-metadata) - mysqli(), load()
33+
- [Debugging](#debugging) - debug()
34+
- [Errors and Exceptions](#errors-and-exceptions)
35+
- [Deprecated Names](#deprecated-names)
36+
- [Gotchas Quick Reference](#gotchas-quick-reference)
3737

3838
---
3939

docs/common-patterns.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ built from methods covered on earlier pages, and the examples assume
55
database rows from [ZenDB](https://github.com/interactivetools-com/ZenDB)
66
or `SmartArrayHtml::new($records)`.
77

8+
Contents:
9+
10+
- [Showing Related Names Without a Join](#showing-related-names-without-a-join)
11+
- [Select Dropdowns from Query Results](#select-dropdowns-from-query-results)
12+
- [Top N with a "More" Link](#top-n-with-a-more-link)
13+
- [Grouped Headings with Counts](#grouped-headings-with-counts)
14+
- [Safe Id Lists for SQL IN Clauses](#safe-id-lists-for-sql-in-clauses)
15+
- [Results with Unpredictable Column Names](#results-with-unpredictable-column-names)
16+
817
## Showing Related Names Without a Join
918

1019
When rows reference another table by id, one keyed map replaces the join:

docs/displaying-fields.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ How to show fields in templates and handle data that isn't there: fallbacks
66
for blank values, "no results" messages, and required records that stop the
77
page.
88

9+
Contents:
10+
11+
- [Reading Fields](#reading-fields)
12+
- [Fallbacks with or()](#fallbacks-with-or)
13+
- [Showing a "No Results" Message](#showing-a-no-results-message)
14+
- [When Data Is Missing](#when-data-is-missing)
15+
- [Requiring Data: The Guards](#requiring-data-the-guards)
16+
- [Checking a Single Field](#checking-a-single-field)
17+
- [Keys Property Syntax Can't Type](#keys-property-syntax-cant-type)
18+
919
## Reading Fields
1020

1121
A SmartArray is an object, not an array, so you read fields with the arrow

docs/filtering-and-sorting.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
How to narrow a loaded result down to the rows you want and put them in the
44
right order: matching, excluding, custom tests, sorting, and duplicates.
55

6+
Contents:
7+
8+
- [Matching Rows: where()](#matching-rows-where)
9+
- [Excluding Rows: whereNot()](#excluding-rows-wherenot)
10+
- [CMS Builder List Fields: whereInList()](#cms-builder-list-fields-whereinlist)
11+
- [Custom Tests: filter()](#custom-tests-filter)
12+
- [Sorting: sortBy() and sort()](#sorting-sortby-and-sort)
13+
- [Duplicates and Membership: unique() and contains()](#duplicates-and-membership-unique-and-contains)
14+
615
## Matching Rows: where()
716

817
Choosing which rows to load is the query's job (SQL's WHERE clause);

docs/getting-started.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ methods, with fields that HTML-encode themselves on output. This page covers
77
installation, your first collection, the mental model behind the two classes,
88
and the everyday basics: loops, field access, and debugging.
99

10+
Contents:
11+
12+
- [Installation](#installation)
13+
- [Your First SmartArray](#your-first-smartarray)
14+
- [The Mental Model](#the-mental-model)
15+
- [Working with ZenDB and CMS Builder](#working-with-zendb-and-cms-builder)
16+
- [Converting to Plain Arrays](#converting-to-plain-arrays)
17+
- [Debugging](#debugging)
18+
1019
## Installation
1120

1221
Using CMS Builder or [ZenDB](https://github.com/interactivetools-com/ZenDB)?

docs/method-reference.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
Every method, grouped by what it returns. Each group heading links to the
44
guide page that teaches those methods.
55

6+
Contents:
7+
8+
- [Basic Usage](#basic-usage)
9+
- [Creation and Conversion](#creation-and-conversion)
10+
- [Single Elements](#single-elements)
11+
- [Writing Values](#writing-values)
12+
- [Collection Checks](#collection-checks)
13+
- [Row Position](#row-position)
14+
- [Filtering and Sorting](#filtering-and-sorting)
15+
- [Transforming and Grouping](#transforming-and-grouping)
16+
- [Requiring Results](#requiring-results)
17+
- [Database Metadata](#database-metadata)
18+
- [Debugging](#debugging)
19+
620
### [Basic Usage](getting-started.md)
721

822
```php

docs/outputting-html.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ The first two pages used auto-encoding without explaining it. This page
66
covers how it works, how to output trusted HTML like WYSIWYG editor content, and
77
the row helpers that control loop layout.
88

9+
Contents:
10+
11+
- [How Auto-Encoding Works](#how-auto-encoding-works)
12+
- [Where Encoding Ends](#where-encoding-ends)
13+
- [Trusted HTML: rawHtml()](#trusted-html-rawhtml)
14+
- [Loop Layout: isFirst(), isLast(), position()](#loop-layout-isfirst-islast-position)
15+
- [Keys Are Never Encoded](#keys-are-never-encoded)
16+
917
## How Auto-Encoding Works
1018

1119
A field holds your original value, exactly as it came from the database,

docs/performance.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ cost hundreds of times more.
1717
The rest of this page is the measurements behind those claims, and the one
1818
case where the overhead is worth thinking about.
1919

20+
Contents:
21+
22+
- [What a Page Costs](#what-a-page-costs)
23+
- [Memory](#memory)
24+
- [When to Care](#when-to-care)
25+
- [Reproducing the Numbers](#reproducing-the-numbers)
26+
2027
## What a Page Costs
2128

2229
A news site with 25 records (60-char title, 300-char summary, 5KB content),

docs/transforming-and-grouping.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
How to reshape a loaded result: pull one column out, key rows for instant
44
lookups, group them for section headings, and rebuild rows into new shapes.
55

6+
Contents:
7+
8+
- [Pulling One Column: column()](#pulling-one-column-column)
9+
- [Keying Rows for Lookups: indexBy()](#keying-rows-for-lookups-indexby)
10+
- [Using Fields as Lookup Keys](#using-fields-as-lookup-keys)
11+
- [Grouping Rows: groupBy()](#grouping-rows-groupby)
12+
- [Reshaping Rows: map()](#reshaping-rows-map)
13+
- [Keys and Values](#keys-and-values)
14+
615
## Pulling One Column: column()
716

817
Use `column()` to get a flat list of one field from every row (like PHP's

docs/troubleshooting.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ Common error messages and how to fix them, plus the gotchas that don't
66
produce an error at all. Headings quote the message or symptom so you can
77
find them by search.
88

9+
Contents:
10+
11+
- [empty() and if() checks on fields don't work as expected](#empty-and-if-checks-on-fields-dont-work-as-expected)
12+
- [A === null check never matches](#a--null-check-never-matches)
13+
- [Warning: Can't convert SmartArrayHtml to string](#warning-cant-convert-smartarrayhtml-to-string)
14+
- [Warning: some_field is undefined in listings.php:12](#warning-some_field-is-undefined-in-listingsphp12)
15+
- [Casting with (array) returns internal object data](#casting-with-array-returns-internal-object-data)
16+
- [json_encode() returns an object instead of an array](#json_encode-returns-an-object-instead-of-an-array)
17+
- [A lookup using a field as the key renders blank](#a-lookup-using-a-field-as-the-key-renders-blank)
18+
919
### empty() and if() checks on fields don't work as expected
1020

1121
In HTML mode a field is an object wrapping your value, and PHP's `empty()`

0 commit comments

Comments
 (0)