Skip to content

Commit f8addff

Browse files
committed
initial additions
1 parent c54bec0 commit f8addff

25 files changed

+11682
-0
lines changed

docs/CLAUDE.md

Lines changed: 483 additions & 0 deletions
Large diffs are not rendered by default.

docs/DESIGN_STANDARDS.md

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
# Design Standards for Twitter Algorithm Documentation
2+
3+
## Navigation Structure
4+
5+
### Current State
6+
We have files in:
7+
- `index.html` (landing page)
8+
- `parts/01-introduction.html`
9+
- `parts/07-appendix.html`
10+
- `interactive/` (6 interactive tools)
11+
12+
### Standard Navigation
13+
14+
**For index.html:**
15+
```html
16+
<nav>
17+
<div class="nav-container">
18+
<h1><a href="index.html">How Twitter's Algorithm Really Works</a></h1>
19+
<ul>
20+
<li><a href="parts/01-introduction.html">Introduction</a></li>
21+
<li><a href="parts/07-appendix.html">Appendix</a></li>
22+
<li><a href="#interactives">Interactives ↓</a></li>
23+
</ul>
24+
</div>
25+
</nav>
26+
```
27+
28+
**For parts/*.html:**
29+
```html
30+
<nav>
31+
<div class="nav-container">
32+
<h1><a href="../index.html">How Twitter's Algorithm Really Works</a></h1>
33+
<ul>
34+
<li><a href="01-introduction.html">Introduction</a></li>
35+
<li><a href="07-appendix.html">Appendix</a></li>
36+
<li><a href="../index.html#interactives">Interactives</a></li>
37+
</ul>
38+
</div>
39+
</nav>
40+
```
41+
42+
**For interactive/*.html:**
43+
```html
44+
<nav>
45+
<div class="nav-container">
46+
<h1><a href="../index.html">How Twitter's Algorithm Really Works</a></h1>
47+
<ul>
48+
<li><a href="../parts/01-introduction.html">Introduction</a></li>
49+
<li><a href="../parts/07-appendix.html">Appendix</a></li>
50+
<li><a href="../index.html#interactives">All Interactives</a></li>
51+
</ul>
52+
</div>
53+
</nav>
54+
```
55+
56+
**Rationale:** Only show what actually exists. Keep it simple.
57+
58+
---
59+
60+
## Code Reference Standard
61+
62+
### Format
63+
64+
All code references should be **clickable GitHub links** to the actual source code.
65+
66+
**Base URL:** `https://github.com/twitter/the-algorithm/blob/main/`
67+
68+
### HTML Pattern
69+
70+
```html
71+
<p class="code-ref">
72+
<strong>Code</strong>:
73+
<a href="https://github.com/twitter/the-algorithm/blob/main/home-mixer/server/src/main/scala/com/twitter/home_mixer/param/HomeGlobalParams.scala#L788-L930" target="_blank" rel="noopener">
74+
<code>home-mixer/server/src/main/scala/com/twitter/home_mixer/param/HomeGlobalParams.scala:788-930</code>
75+
</a>
76+
</p>
77+
```
78+
79+
### Line Number Formats
80+
81+
- **Single line**: `file.scala:123` → GitHub URL ends with `#L123`
82+
- **Range**: `file.scala:123-456` → GitHub URL ends with `#L123-L456`
83+
- **Multiple lines**: `file.scala:123,145,167` → Link to first line `#L123` (GitHub doesn't support non-contiguous)
84+
85+
### Helper Function (JavaScript)
86+
87+
```javascript
88+
/**
89+
* Convert file path with line numbers to GitHub URL
90+
* @param {string} path - e.g., "home-mixer/server/.../file.scala:123-456"
91+
* @returns {string} GitHub URL
92+
*/
93+
function codeRefToGitHubUrl(path) {
94+
const baseUrl = 'https://github.com/twitter/the-algorithm/blob/main/';
95+
96+
// Handle root-level files (no slashes before colon)
97+
if (path.includes(':')) {
98+
const [file, lines] = path.split(':');
99+
const lineFragment = lines.includes('-')
100+
? `#L${lines.replace('-', '-L')}`
101+
: `#L${lines}`;
102+
return baseUrl + file + lineFragment;
103+
}
104+
105+
// No line numbers, just file
106+
return baseUrl + path;
107+
}
108+
109+
// Example usage:
110+
// codeRefToGitHubUrl("home-mixer/server/src/main/scala/.../HomeGlobalParams.scala:788-930")
111+
// Returns: "https://github.com/twitter/the-algorithm/blob/main/home-mixer/server/src/main/scala/.../HomeGlobalParams.scala#L788-L930"
112+
```
113+
114+
### CSS Styling
115+
116+
```css
117+
/* Code reference links */
118+
.code-ref a {
119+
color: var(--primary-color);
120+
text-decoration: none;
121+
transition: color 0.2s;
122+
display: inline-flex;
123+
align-items: center;
124+
gap: 0.25rem;
125+
}
126+
127+
.code-ref a:hover {
128+
color: var(--primary-hover);
129+
text-decoration: underline;
130+
}
131+
132+
.code-ref a::after {
133+
content: "";
134+
font-size: 0.875em;
135+
opacity: 0.6;
136+
}
137+
138+
.code-ref code {
139+
background-color: var(--code-bg);
140+
border: 1px solid var(--code-border);
141+
border-radius: 3px;
142+
padding: 0.2em 0.4em;
143+
font-size: 0.8em;
144+
}
145+
```
146+
147+
### Examples
148+
149+
**Before (plain text):**
150+
```html
151+
<p class="code-ref">
152+
<strong>Code</strong>: <code>home-mixer/server/src/main/scala/com/twitter/home_mixer/param/HomeGlobalParams.scala:788-930</code>
153+
</p>
154+
```
155+
156+
**After (clickable link):**
157+
```html
158+
<p class="code-ref">
159+
<strong>Code</strong>:
160+
<a href="https://github.com/twitter/the-algorithm/blob/main/home-mixer/server/src/main/scala/com/twitter/home_mixer/param/HomeGlobalParams.scala#L788-L930" target="_blank" rel="noopener">
161+
<code>home-mixer/server/src/main/scala/com/twitter/home_mixer/param/HomeGlobalParams.scala:788-930</code>
162+
</a>
163+
</p>
164+
```
165+
166+
**Special Cases:**
167+
168+
1. **Root-level files** (like RETREIVAL_SIGNALS.md):
169+
```html
170+
<a href="https://github.com/twitter/the-algorithm/blob/main/RETREIVAL_SIGNALS.md" target="_blank" rel="noopener">
171+
<code>RETREIVAL_SIGNALS.md</code>
172+
</a>
173+
```
174+
175+
2. **External repo** (algorithm-ml):
176+
```html
177+
<a href="https://github.com/twitter/the-algorithm-ml/blob/main/projects/home/recap/README.md" target="_blank" rel="noopener">
178+
<code>the-algorithm-ml/projects/home/recap/README.md</code>
179+
</a>
180+
```
181+
182+
---
183+
184+
## File Organization
185+
186+
```
187+
docs/
188+
├── index.html # Landing page with overview
189+
├── DESIGN_STANDARDS.md # This file (design guidelines)
190+
├── README.md # How to view/deploy
191+
├── CLAUDE.md # AI assistant guidelines
192+
193+
├── parts/ # Main content sections
194+
│ ├── 01-introduction.html
195+
│ └── 07-appendix.html
196+
197+
├── interactive/ # Interactive visualizations
198+
│ ├── cluster-explorer.html
199+
│ ├── engagement-calculator.html
200+
│ ├── invisible-filter.html
201+
│ ├── journey-simulator.html
202+
│ ├── pipeline-explorer.html
203+
│ └── reinforcement-loop.html
204+
205+
├── js/ # JavaScript for interactives
206+
│ ├── cluster-explorer.js
207+
│ ├── engagement-calculator.js
208+
│ ├── invisible-filter.js
209+
│ ├── journey-simulator.js
210+
│ ├── pipeline-explorer.js
211+
│ └── reinforcement-loop.js
212+
213+
├── css/
214+
│ └── style.css # Global styles
215+
216+
└── assets/ # Static assets (if needed)
217+
└── data/ # JSON data files
218+
```
219+
220+
---
221+
222+
## Migration Plan
223+
224+
### Step 1: Update Navigation (All Files)
225+
- Remove links to non-existent parts (02-06)
226+
- Update navigation HTML in:
227+
- `index.html`
228+
- `parts/01-introduction.html`
229+
- `parts/07-appendix.html`
230+
- All `interactive/*.html` files
231+
232+
### Step 2: Add Code Reference Styling
233+
- Add CSS to `css/style.css`
234+
235+
### Step 3: Convert Code References
236+
- Find all `.code-ref` instances across all HTML files
237+
- Convert plain text paths to clickable GitHub links
238+
- Use the standard format above
239+
240+
### Step 4: Test
241+
- Open each page and verify:
242+
- Navigation links work
243+
- Code reference links go to correct GitHub locations
244+
- No broken links
245+
246+
---
247+
248+
## Checklist for New Pages
249+
250+
When creating a new page, ensure:
251+
252+
- [ ] Navigation uses the standard format (only existing pages)
253+
- [ ] All code references are clickable GitHub links
254+
- [ ] Footer includes page navigation (Previous/Next if applicable)
255+
- [ ] Page uses `css/style.css`
256+
- [ ] Title follows pattern: "Page Title - How Twitter's Algorithm Really Works"
257+
- [ ] Meta description included
258+
- [ ] Links to related interactives where relevant
259+
260+
---
261+
262+
## Notes
263+
264+
- **Why GitHub links?** Users can verify claims by reading the actual code
265+
- **Why simplified nav?** Don't promise what doesn't exist yet
266+
- **target="_blank"** and **rel="noopener"**: Security best practice for external links
267+
- **Line number format**: GitHub uses `#L123` for single line, `#L123-L456` for ranges

0 commit comments

Comments
 (0)