<commit_before><?php

/**
 * This file is part of the Schematicon library.
 * @license    MIT
 * @link       https://github.com/schematicon/doc-generator
 */

namespace Schematicon\DocGenerator;

use Latte\Engine;
use Latte\Runtime\Html;
use Texy\Texy;


class Generator
{
	public function generate($apiSpecification)
	{
		$texy = new Texy();

		$latte = new Engine();
		$latte->setTempDirectory(__DIR__ . '/../temp');
		$latte->addFilter('urlvars', function ($url) {
			return new Html(preg_replace('#(\{[\w_]+\})#', '<span class="url-var">\1</span>', $url));
		});
		$latte->addFilter('texy', function ($content) use ($texy) {
			return new Html($texy->process($content));
		});
		return $latte->renderToString(__DIR__ . '/templates/content.latte', [
			'api' => $apiSpecification,
			'loadReference' => function ($name) use ($apiSpecification) {
				if (!isset($apiSpecification['resources'][$name])) {
					throw new \RuntimeException("References $name schema not found.");
				}
				return $apiSpecification['resources'][$name];
			},
		]);
	}
}<commit_msg>generator: top heading in description is h4<commit_after><?php

/**
 * This file is part of the Schematicon library.
 * @license    MIT
 * @link       https://github.com/schematicon/doc-generator
 */

namespace Schematicon\DocGenerator;

use Latte\Engine;
use Latte\Runtime\Html;
use Texy\Texy;


class Generator
{
	public function generate($apiSpecification)
	{
		$texy = new Texy();
		$texy->headingModule->top = 4;

		$latte = new Engine();
		$latte->setTempDirectory(__DIR__ . '/../temp');
		$latte->addFilter('urlvars', function ($url) {
			return new Html(preg_replace('#(\{[\w_]+\})#', '<span class="url-var">\1</span>', $url));
		});
		$latte->addFilter('texy', function ($content) use ($texy) {
			return new Html($texy->process($content));
		});
		return $latte->renderToString(__DIR__ . '/templates/content.latte', [
			'api' => $apiSpecification,
			'loadReference' => function ($name) use ($apiSpecification) {
				if (!isset($apiSpecification['resources'][$name])) {
					throw new \RuntimeException("References $name schema not found.");
				}
				return $apiSpecification['resources'][$name];
			},
		]);
	}
}
{'fraction_non_alphanumeric': 0.18838591678097852, 'fraction_numerical': 0.001828989483310471, 'mean_word_length': 4.184834123222749, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1500822', 'n_tokens_mistral': 790, 'n_tokens_neox': 716, 'n_words': 152}