Skip to content

Commit 027e18e

Browse files
Update README
1 parent 8267311 commit 027e18e

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The SWE-bench website for leaderboards and project information.
2121
- [How the Website Works](#how-the-website-works)
2222
- [Build Process](#build-process)
2323
- [Template System](#template-system)
24+
- [Leaderboard Data Flow](#leaderboard-data-flow)
2425
- [CSS Organization](#css-organization)
2526
- [JavaScript Usage](#javascript-usage)
2627
- [Customizing the Website](#customizing-the-website)
@@ -151,6 +152,65 @@ Templates use Jinja2 syntax for:
151152
- Variable rendering (`{{ variable }}`)
152153
- Control structures (`{% if condition %}{% endif %}`)
153154

155+
### Leaderboard Data Flow
156+
157+
The leaderboard data follows a specific flow from JSON to rendered HTML:
158+
159+
1. **Data Source**: All leaderboard data is stored in `data/leaderboards.json`. This JSON file contains an array of leaderboards under the key `"leaderboards"`, with each leaderboard having a `"name"` (e.g., "Test", "Lite", "Verified", "Multimodal") and a list of `"results"` entries.
160+
161+
2. **Data Loading**: During the build process in `build.py`, the JSON file is loaded and passed to the Jinja2 templates as the `leaderboards` variable:
162+
```python
163+
# From build.py
164+
with open(ROOT / "data/leaderboards.json", "r") as f:
165+
leaderboards = json.load(f)
166+
167+
# Passed to templates during rendering
168+
html = tpl.render(
169+
title="SWE-bench",
170+
leaderboards=leaderboards["leaderboards"]
171+
)
172+
```
173+
174+
3. **Reusable Table Component**: The `_leaderboard_table.html` template is a reusable component that loops through the leaderboards array and renders a table for each one:
175+
```html
176+
{% for leaderboard in leaderboards %}
177+
<div class="tabcontent" id="leaderboard-{{leaderboard.name}}">
178+
<table class="table table-striped scrollable data-table">
179+
<!-- Table headers -->
180+
<tbody>
181+
{% for item in leaderboard.results if not item.warning %}
182+
<tr>
183+
<!-- Row data from each result item -->
184+
</tr>
185+
{% endfor %}
186+
</tbody>
187+
</table>
188+
</div>
189+
{% endfor %}
190+
```
191+
192+
4. **Page-Specific Rendering**: In page templates like `lite.html`, the leaderboard data can be rendered in a more focused way by filtering for a specific leaderboard:
193+
```html
194+
{% for leaderboard in leaderboards %}
195+
{% if leaderboard.name == "Lite" %}
196+
<table class="table table-striped scrollable data-table">
197+
<!-- Only renders the "Lite" leaderboard -->
198+
</table>
199+
{% endif %}
200+
{% endfor %}
201+
```
202+
203+
5. **Dynamic Badges and Formatting**: The templates add special badges and formatting to entries:
204+
- Medal emoji (🥇, 🥈, 🥉) for the top 3 entries
205+
- "New" badge (🆕) for recent submissions
206+
- "Open source" badge (🤠) when `item.oss` is true
207+
- "Verified" checkmark (✅) when `item.verified` is true
208+
- Percentage formatting with 2 decimal places: `{{ "%.2f"|format(item.resolved|float) }}`
209+
210+
6. **JavaScript Enhancements**: After the HTML is rendered, JavaScript files like `mainResults.js`, `tableByRepo.js`, and `tableByYear.js` enhance the tables with sorting, filtering, and tab switching functionality.
211+
212+
This modular approach allows for easy updates to leaderboard data - simply modify the JSON file, and the changes will propagate throughout the site during the next build.
213+
154214
### CSS Organization
155215

156216
CSS is organized into modular files and imported through `main.css`:

0 commit comments

Comments
 (0)