Skip to content

Commit f81c0ab

Browse files
committed
Add docs and deploy workflow
1 parent fc709d3 commit f81c0ab

File tree

6 files changed

+176
-0
lines changed

6 files changed

+176
-0
lines changed

.github/workflows/documentation.yaml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: "Documentation"
2+
3+
on: # yamllint disable-line rule:truthy
4+
push:
5+
branches:
6+
- "1.x"
7+
pull_request: null
8+
9+
jobs:
10+
documentation:
11+
name: "Documentation"
12+
runs-on: "ubuntu-latest"
13+
steps:
14+
- name: "Checkout"
15+
uses: "actions/checkout@v4"
16+
17+
- name: "Build"
18+
uses: "phpDocumentor/phpDocumentor@main"
19+
20+
- name: "Deploy"
21+
if: "${{ github.event_name == 'push' && github.ref == 'refs/heads/1.x' }}"
22+
uses: "upload-artifact@v4"
23+
with:
24+
name: "documentation"
25+
path: "build/docs"
26+
retention-days: 1
27+
28+
deploy:
29+
name: "Deploy"
30+
if: "${{ github.event_name == 'push' && github.ref == 'refs/heads/1.x' }}"
31+
runs-on: "ubuntu-latest"
32+
needs: "documentation"
33+
steps:
34+
- name: "Checkout"
35+
uses: "actions/checkout@v4"
36+
with:
37+
repository: "phpDocumentor/docs"
38+
token: "${{ secrets.BOT_TOKEN }}"
39+
path: 'docs'
40+
41+
- name: "Download"
42+
uses: "actions/download-artifact@v4"
43+
with:
44+
name: "documentation"
45+
path: "build/docs"
46+
47+
- name: "Copy files"
48+
run: "cp -r build/docs docs/type-resolver"
49+
50+
- name: "Commit"
51+
run: |
52+
cd docs
53+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
54+
git config --local user.name "github-actions[bot]"
55+
git commit -a -m "Update type-resolver documentation"
56+
57+
- name: "Push"
58+
uses: "ad-m/github-push-action@master"
59+
with:
60+
directory: "docs"
61+
token: "${{ secrets.BOT_TOKEN }}"
62+
repository: "phpDocumentor/docs"

.phpdoc/template/base.html.twig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% extends 'layout.html.twig' %}
2+
3+
{% set topMenu = {
4+
"menu": [
5+
{ "name": "About", "url": "https://phpdoc.org/"},
6+
{ "name": "Components", "url": "https://phpdoc.org/components.html"},
7+
{ "name": "Documentation", "url": "https://docs.phpdoc.org/"},
8+
],
9+
"social": [
10+
{ "iconClass": "fab fa-mastodon", "url": "https://phpc.social/@phpdoc"},
11+
{ "iconClass": "fab fa-github", "url": "https://github.com/phpdocumentor/typeresolver"},
12+
{ "iconClass": "fas fa-envelope-open-text", "url": "https://github.com/orgs/phpDocumentor/discussions"}
13+
]
14+
}
15+
%}

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ rector: ## Refactor code using rector
4141

4242
.PHONY: pre-commit-test
4343
pre-commit-test: fix-code-style test code-style static-code-analysis
44+
45+
.PHONY: docs
46+
docs: ## Generate documentation with phpDocumentor
47+
docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project phpdoc/phpdoc:3

docs/getting-started.rst

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
===============
2+
Getting started
3+
===============
4+
5+
On this page you will find a brief introduction on how to use the TypeResolver in your project.
6+
7+
Installation
8+
============
9+
10+
The TypeResolver is available on Packagist and can be installed using Composer:
11+
12+
.. code:: bash
13+
composer require phpdocumentor/type-resolver
14+
15+
16+
General usage
17+
===========
18+
19+
After you installed the TypeResolver you can use it in your project. This can be done by creating a new instance
20+
of the :php:class:`\phpDocumentor\Reflection\TypeResolver` class and calling
21+
:php:method:`\phpDocumentor\Reflection\TypeResolver::resolve()` with the type you want to resolve.
22+
23+
.. code:: php
24+
$typeResolver = new \phpDocumentor\Reflection\TypeResolver();
25+
$type = $typeResolver->resolve('string');
26+
echo get_class($type); // phpDocumentor\Reflection\Types\String_
27+
28+
The real power of this resolver is in its capability to expand partial class names into fully qualified class names;
29+
but in order to do that we need an additional :php:class:`\phpDocumentor\Reflection\Types\Context` class that
30+
will inform the resolver in which namespace the given expression occurs and which namespace aliases (or imports) apply.
31+
32+
Read more about the Context class in the next section.

docs/index.rst

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=============
2+
Type resolver
3+
=============
4+
5+
This project part of the phpDocumentor project. It is capable of creating an object structure of the type
6+
specifications found in the PHPDoc blocks of a project. This can be useful for static analysis of a project
7+
or other behavior that requires knowledge of the types used in a project like automatically build forms.
8+
9+
This project aims to cover all types that are available in PHPDoc and PHP itself. And is open for extension by
10+
third party developers.
11+
12+
.. toctree::
13+
:maxdepth: 2
14+
:hidden:
15+
16+
index
17+
getting-started

phpdoc.dist.xml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<phpdocumentor
3+
configVersion="3"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns="https://www.phpdoc.org"
6+
xsi:noNamespaceSchemaLocation="data/xsd/phpdoc.xsd"
7+
>
8+
<title>Type Resolver</title>
9+
<paths>
10+
<output>build/docs</output>
11+
</paths>
12+
<version number="0.2.0">
13+
<folder>latest</folder>
14+
<api>
15+
<source dsn="./">
16+
<path>src/</path>
17+
</source>
18+
<output>api</output>
19+
<ignore hidden="true" symlinks="true">
20+
<path>tests/**/*</path>
21+
<path>build/**/*</path>
22+
<path>var/**/*</path>
23+
<path>vendor/**/*</path>
24+
</ignore>
25+
<extensions>
26+
<extension>php</extension>
27+
</extensions>
28+
<ignore-tags>
29+
<ignore-tag>template</ignore-tag>
30+
<ignore-tag>template-extends</ignore-tag>
31+
<ignore-tag>template-implements</ignore-tag>
32+
<ignore-tag>extends</ignore-tag>
33+
<ignore-tag>implements</ignore-tag>
34+
</ignore-tags>
35+
<default-package-name>phpDocumentor</default-package-name>
36+
</api>
37+
<guide>
38+
<source dsn=".">
39+
<path>docs</path>
40+
</source>
41+
<output>guides</output>
42+
</guide>
43+
</version>
44+
<setting name="guides.enabled" value="true"/>
45+
<template name="default" />
46+
</phpdocumentor>

0 commit comments

Comments
 (0)