Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A clean and modern Bootstrap-based template for phpDocumentor, designed to impro
- Responsive and mobile-friendly
- Styled code blocks and documentation elements
- Improved tables of contents and element listings
- Designed for documentation sets that provide guides

## Installation

Expand All @@ -28,7 +29,7 @@ composer require --dev fast-forward/phpdoc-bootstrap-template

## Usage

Reference the template from vendor in your phpdoc.xml:
Reference the template from vendor in your phpdoc.xml. This template is designed for projects that ship guides, and the guide output should point to the documentation root (`.`) so the guide index becomes the homepage:

```xml
<?xml version="1.0" encoding="UTF-8" ?>
Expand All @@ -47,6 +48,12 @@ Reference the template from vendor in your phpdoc.xml:
<path>src</path>
</source>
</api>
<guide format="rst">
<source dsn=".">
<path>docs</path>
</source>
<output>.</output>
</guide>
</version>

<template name="vendor/fast-forward/phpdoc-bootstrap-template" />
Expand All @@ -65,6 +72,8 @@ Or with a config file:
vendor/bin/phpdoc --config phpdoc.xml
```

With this setup, the guide `index` document is rendered as the root `index.html`.

## Requirements

- PHP 8.3+
Expand All @@ -88,4 +97,4 @@ Contributions are welcome. Please open an issue or submit a pull request.

## 📄 License

This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
12 changes: 6 additions & 6 deletions components/sidebar.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@
<ul class="nav nav-pills flex-column">
{% if project.settings.custom['graphs.enabled'] %}
<li class="nav-item">
<a class="nav-link link-body-emphasis d-flex align-items-center gap-2" href="graphs/classes.html">
<a class="nav-link link-body-emphasis d-flex align-items-center gap-2" href="{{ path('graphs/classes.html') }}">
<i class="fas fa-project-diagram text-primary"></i>
<span>Class Diagram</span>
</a>
</li>
{% endif %}
<li class="nav-item">
<a class="nav-link link-body-emphasis d-flex align-items-center gap-2" href="reports/deprecated.html">
<a class="nav-link link-body-emphasis d-flex align-items-center gap-2" href="{{ path('reports/deprecated.html') }}">
<i class="fas fa-exclamation-triangle text-warning"></i>
<span>Deprecated</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link link-body-emphasis d-flex align-items-center gap-2" href="reports/errors.html">
<a class="nav-link link-body-emphasis d-flex align-items-center gap-2" href="{{ path('reports/errors.html') }}">
<i class="fas fa-bug text-danger"></i>
<span>Errors</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link link-body-emphasis d-flex align-items-center gap-2" href="reports/markers.html">
<a class="nav-link link-body-emphasis d-flex align-items-center gap-2" href="{{ path('reports/markers.html') }}">
<i class="fas fa-bookmark text-info"></i>
<span>Markers</span>
</a>
Expand All @@ -61,12 +61,12 @@

<ul class="nav nav-pills flex-column">
<li class="nav-item">
<a class="nav-link link-body-emphasis d-flex align-items-center gap-2" href="indices/files.html">
<a class="nav-link link-body-emphasis d-flex align-items-center gap-2" href="{{ path('indices/files.html') }}">
<i class="fas fa-file-code text-secondary"></i>
<span>Files</span>
</a>
</li>
</ul>
</li>
</ul>
</nav>
</nav>
5 changes: 2 additions & 3 deletions graphs/class.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends 'base.html.twig' %}
{% set baseUrl = renderBaseUrlHeader() %}

{% block stylesheets %}
{% endblock %}
Expand Down Expand Up @@ -40,7 +39,7 @@
id="graph-container"
>
<img
src="graphs/classes.svg"
src="{{ path('graphs/classes.svg') }}"
id="scene"
alt="Class diagram"
class="img-fluid d-block mx-auto"
Expand Down Expand Up @@ -88,4 +87,4 @@
});
})();
</script>
{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions js/search.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var Search = (function () {
var summary = result.summary ? escapeHtml(result.summary) : '';
var fqsen = result.fqsen ? escapeHtml(result.fqsen) : '';
var name = escapeHtml(result.name || 'Untitled');
var url = document.baseURI + result.url;
var url = result.url;

return '' +
'<li class="list-group-item px-3 py-3">' +
Expand Down Expand Up @@ -208,4 +208,4 @@ window.addEventListener('DOMContentLoaded', function () {

window.addEventListener('load', function () {
Search.init();
});
});
1 change: 0 additions & 1 deletion js/searchIndex.js.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{% set baseUrl = renderBaseUrlHeader() %}
Search.appendIndex(
[
{% for element in project.indexes.elements %}
Expand Down
33 changes: 28 additions & 5 deletions layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,31 @@
<title>{% block title %}{{ project.name }}{% endblock %}</title>
{% endblock %}

{% set currentDestination = destinationPath|default('') %}
{% if (currentDestination is empty) and env is not null %}
{% set currentDestination = env.currentFileDestination|default('') %}
{% endif %}

{% set normalizedDestination = currentDestination
|split('#')|first
|split('?')|first
|replace({'./': '', '.\\': ''})
|trim('/')
%}

{% set destinationDepth = normalizedDestination ? (normalizedDestination|split('/')|length - 1) : 0 %}
{% set baseHref = './' %}

{% if destinationDepth > 0 %}
{% set baseSegments = [] %}
{% for i in 1..destinationDepth %}
{% set baseSegments = baseSegments|merge(['../']) %}
{% endfor %}
{% set baseHref = baseSegments|join('') %}
{% endif %}

<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{ renderBaseUrlHeader() }}
<base href="{{ baseHref }}">

{% block stylesheets %}
<!-- Bootstrap -->
Expand All @@ -20,7 +43,7 @@

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">

<link rel="stylesheet" href="{{ template_path }}css/base.css">
<link rel="stylesheet" href="{{ path('css/base.css') }}">
{% endblock %}
</head>
<body>
Expand Down Expand Up @@ -84,9 +107,9 @@

<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>

<script src="js/template.js"></script>
<script src="js/search.js"></script>
<script defer src="js/searchIndex.js"></script>
<script src="{{ path('js/template.js') }}"></script>
<script src="{{ path('js/search.js') }}"></script>
<script defer src="{{ path('js/searchIndex.js') }}"></script>
{% endblock %}
</body>
</html>
1 change: 0 additions & 1 deletion template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<email>github@mentordosnerds.com</email>
<version>1.0.0</version>
<transformations>
<transformation writer="twig" source="index.html.twig" artifact="index.html"/>
<transformation writer="twig" query="files" source="file.html.twig" />
<transformation writer="sourcecode" query="files" source="source/file.source.txt.twig" artifact="files/{{path}}.txt" />
<transformation writer="twig" query="indexes.namespaces" source="namespace.html.twig" />
Expand Down