-
Notifications
You must be signed in to change notification settings - Fork 269
/
Copy pathtoc.php
33 lines (26 loc) · 1007 Bytes
/
toc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php error_reporting(E_ALL);
require __DIR__ . '/util.php';
$dir = __DIR__ . '/../spec/';
$tocFile = $dir . '00-specification-for-php.md';
$prefix = <<<EOS
<!-- This file is autogenerated, do not edit it manually -->
<!-- Run tools/toc.php instead -->
# Specification for PHP
Facebook has dedicated all copyright to this specification to the public
domain worldwide under the CC0 Public Domain Dedication located at
<http://creativecommons.org/publicdomain/zero/1.0/>. This specification
is distributed without any warranty.
(Initially written in 2014 by Facebook, Inc., July 2014)
**Table of Contents**
EOS;
$output = "";
foreach (spec_files() as $fileName => $path) {
$contents = file_get_contents($path);
foreach (heading_info($contents) as $info) {
$title = $info['title'];
$anchor = $info['anchor'];
$indent = str_repeat(' ', $info['level']);
$output .= "$indent- [$title]($fileName#$anchor)\n";
}
}
file_put_contents($tocFile, "$prefix\n$output");