Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpdoc + examples #65

Merged
merged 18 commits into from
Oct 16, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.idea/
.php-cs-fixer.cache
.phpunit.cache/
.phpdoc/cache
composer.lock
test*.php
vendor/
Expand All @@ -10,3 +11,5 @@ vendor/
/website/content/.vitepress/dist/
/website/content/.vitepress/cache/
/website/node_modules/
/private
/test*.*
13 changes: 13 additions & 0 deletions .phpdoc/template/base.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends 'layout.html.twig' %}

{%
set topMenu = {
"menu": [
{ "name": "What is Nostr?", "url": "https://nostr.how"}
],
"social": [
{ "iconClass": "fab fa-telegram", "url": "https://t.me/nostr_php"},
{ "iconClass": "fab fa-github", "url": "https://github.com/nostrver-se/nostr-php"}
]
}
%}
54 changes: 54 additions & 0 deletions .phpdoc/template/components/header-title.css.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.phpdocumentor-title {
box-sizing: border-box;
color: var(--title-text-color);
font-size: var(--text-xxl);
letter-spacing: .05rem;
font-weight: normal;
width: auto;
margin: 0;
display: flex;
align-items: center;
}

.phpdocumentor-title.-without-divider {
border: none;
}

.phpdocumentor-title__link {
transition: all .3s ease-out;
display: flex;
color: var(--title-text-color);
text-decoration: none;
font-weight: normal;
white-space: nowrap;
transform: scale(.75);
transform-origin: left;
}

.phpdocumentor-title__link:hover {
transform: perspective(15rem) translateX(.5rem);
font-weight: 600;
}

@media (min-width: {{ breakpoints['menu'] }}) {
.phpdocumentor-title {
width: 22%;
border-right: var(--sidebar-border-color) solid 1px;
}

.phpdocumentor-title__link {
transform-origin: left;
}
}

@media (min-width: {{ breakpoints['xl'] }}) {
.phpdocumentor-title__link {
transform: scale(.85);
}
}

@media (min-width: {{ breakpoints['xxl'] }}) {
.phpdocumentor-title__link {
transform: scale(1);
}
}
1 change: 1 addition & 0 deletions .phpdoc/template/components/header-title.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1 class="phpdocumentor-title"><a href="{{ path('/') }}" class="phpdocumentor-title__link">{{ project.name }}</a></h1>
37 changes: 37 additions & 0 deletions .phpdoc/template/components/sidebar.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
Menu
</label>
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
<section class="phpdocumentor-sidebar__category">
<h2 class="phpdocumentor-sidebar__category-header">
<a href="namespaces/swentel-nostr-examples.html">Examples</a>
</h2>
</section>

{% for version in project.versions %}
{% for toc in version.tableOfContents %}
<section class="phpdocumentor-sidebar__category -{{ toc.name|lower }}">
<h2 class="phpdocumentor-sidebar__category-header">{{ toc.name|title }}</h2>
{% for root in toc.roots %}
{{ toc(root, 'components/menu.html.twig', 1) }}
{% endfor %}
</section>
{% endfor %}
{% endfor %}

<section class="phpdocumentor-sidebar__category -reports">
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
{% if project.settings.custom['graphs.enabled'] %}
<h3 class="phpdocumentor-sidebar__root-package"><a href="graphs/classes.html">Class Diagram</a></h3>
{% endif %}
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
</section>

<section class="phpdocumentor-sidebar__category -indices">
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
</section>
</aside>
1 change: 1 addition & 0 deletions .phpdoc/template/css/custom.css.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{# this file is meant as a catch-all location for consumers to provide overrides without having to override specific parts #}
3 changes: 3 additions & 0 deletions .phpdoc/template/homepage.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% block content %}
Custom homepage template here
{% endblock %}
22 changes: 22 additions & 0 deletions .phpdoc/template/index.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends 'base.html.twig' %}

{% block content %}
<section>
<h2>{{ project.name }} documentation</h2>

{% set node = project.namespace %}

{{
include(
'components/table-of-contents.html.twig',
{
'node': project.namespace,
'namespaces': usesNamespaces or not usesPackages ? node.children : [],
'packages': usesPackages ? project.package.children : []
}
)
}}
{{ include('components/constants.html.twig', {'node': project.namespace}) }}
{{ include('components/functions.html.twig', {'node': project.namespace}) }}
</section>
{% endblock %}
64 changes: 64 additions & 0 deletions .phpdoc/template/layout.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
{% block head %}
<title>{% block title %}{{ project.name }}{% endblock %}</title>
{% endblock %}

<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{ renderBaseUrlHeader() }}
<link rel="icon" href="images/favicon.ico"/>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/base.css">
{% block stylesheets %}
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/template.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism-okaidia.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/plugins/line-numbers/prism-line-numbers.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/plugins/line-highlight/prism-line-highlight.css">
{% endblock %}
{% block javascripts %}
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
<script src="js/template.js"></script>
<script src="js/search.js"></script>
<script defer src="js/searchIndex.js"></script>
{% endblock %}
</head>
<body id="top">
{% include 'components/header.html.twig' %}

<main class="phpdocumentor">
<div class="phpdocumentor-section">
{% include 'components/sidebar.html.twig' %}

<div class="phpdocumentor-column -nine phpdocumentor-content">
{% if block('on_this_page') is defined %}
<section>
{% endif %}
{% block content %}{% endblock %}
{% if block('on_this_page') is defined %}
</section>
<section class="phpdocumentor-on-this-page__sidebar">
{{ block('on_this_page') }}
</section>
{% endif %}
</div>
{% include 'components/search-results.html.twig' %}
</div>
{{ include('components/back-to-top.html.twig') }}
</main>

<script>
cssVars({});
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/prism.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/autoloader/prism-autoloader.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/line-numbers/prism-line-numbers.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/line-highlight/prism-line-highlight.min.js"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions .phpdoc/template/template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<template>
<name>phpdoc</name>
<author>Sebastian Hagens</author>
<email>[email protected]</email>
<version>1.0.0</version>
<extends>default</extends>
<transformations>
<!-- Add your transformations here -->
<transformation writer="twig" source="homepage.html.twig" artifact="homepage.html"/>
</transformations>
</template>
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,19 @@ All tests can be found in `tests`.
$ php vendor/bin/phpunit
```

## Documentation with phpDocumentor

Generate documentation with [phpDocumentor](https://phpdoc.org/).

```console
$ phpdoc
```

All documentation is saved in the `phpdoc.nostr-php.dev` directory where the `index.html` can be opened in any browser.
This directory also serves as the root directory for https://phpdoc.nostr-php.dev.

The documentation of phpDocumentor can be found at https://docs.phpdoc.org/.

## nostr-php script (cli client)

The library ships with a simple CLI client (`bin/nostr-php`) to post a short text note to a Nostr relay.
Expand Down
20 changes: 20 additions & 0 deletions phpdoc.dist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpdocumentor
configVersion="3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.phpdoc.org"
>
<title>nostr-php</title>
<paths>
<output>phpdoc.nostr-php.dev</output>
</paths>
<version number="3">
<api format="php">
<source dsn=".">
<path>bin</path>
<path>src</path>
<path>tests</path>
</source>
</api>
</version>
</phpdocumentor>
Loading
Loading