Skip to content

Commit 4c590de

Browse files
committed
Merge pull request #6 from phpcr/restructured_text
[RFC] Migrated to Sphinx
2 parents 4fa0382 + 6960b95 commit 4c590de

29 files changed

+1571
-776
lines changed

Makefile

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
PAPER =
8+
BUILDDIR = _build
9+
10+
# Internal variables.
11+
PAPEROPT_a4 = -D latex_paper_size=a4
12+
PAPEROPT_letter = -D latex_paper_size=letter
13+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
14+
# the i18n builder cannot share the environment and doctrees with the others
15+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
16+
17+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
18+
19+
help:
20+
@echo "Please use \`make <target>' where <target> is one of"
21+
@echo " html to make standalone HTML files"
22+
@echo " dirhtml to make HTML files named index.html in directories"
23+
@echo " singlehtml to make a single large HTML file"
24+
@echo " pickle to make pickle files"
25+
@echo " json to make JSON files"
26+
@echo " htmlhelp to make HTML files and a HTML help project"
27+
@echo " qthelp to make HTML files and a qthelp project"
28+
@echo " devhelp to make HTML files and a Devhelp project"
29+
@echo " epub to make an epub"
30+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
31+
@echo " latexpdf to make LaTeX files and run them through pdflatex"
32+
@echo " text to make text files"
33+
@echo " man to make manual pages"
34+
@echo " texinfo to make Texinfo files"
35+
@echo " info to make Texinfo files and run them through makeinfo"
36+
@echo " gettext to make PO message catalogs"
37+
@echo " changes to make an overview of all changed/added/deprecated items"
38+
@echo " linkcheck to check all external links for integrity"
39+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
40+
41+
clean:
42+
-rm -rf $(BUILDDIR)/*
43+
44+
html:
45+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
46+
@echo
47+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
48+
49+
dirhtml:
50+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
51+
@echo
52+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
53+
54+
singlehtml:
55+
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
56+
@echo
57+
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
58+
59+
pickle:
60+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
61+
@echo
62+
@echo "Build finished; now you can process the pickle files."
63+
64+
json:
65+
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
66+
@echo
67+
@echo "Build finished; now you can process the JSON files."
68+
69+
htmlhelp:
70+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
71+
@echo
72+
@echo "Build finished; now you can run HTML Help Workshop with the" \
73+
".hhp project file in $(BUILDDIR)/htmlhelp."
74+
75+
qthelp:
76+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
77+
@echo
78+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
79+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
80+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PHPCR.qhcp"
81+
@echo "To view the help file:"
82+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PHPCR.qhc"
83+
84+
devhelp:
85+
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
86+
@echo
87+
@echo "Build finished."
88+
@echo "To view the help file:"
89+
@echo "# mkdir -p $$HOME/.local/share/devhelp/PHPCR"
90+
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PHPCR"
91+
@echo "# devhelp"
92+
93+
epub:
94+
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
95+
@echo
96+
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
97+
98+
latex:
99+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
100+
@echo
101+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
102+
@echo "Run \`make' in that directory to run these through (pdf)latex" \
103+
"(use \`make latexpdf' here to do that automatically)."
104+
105+
latexpdf:
106+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
107+
@echo "Running LaTeX files through pdflatex..."
108+
$(MAKE) -C $(BUILDDIR)/latex all-pdf
109+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
110+
111+
text:
112+
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
113+
@echo
114+
@echo "Build finished. The text files are in $(BUILDDIR)/text."
115+
116+
man:
117+
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
118+
@echo
119+
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
120+
121+
texinfo:
122+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
123+
@echo
124+
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
125+
@echo "Run \`make' in that directory to run these through makeinfo" \
126+
"(use \`make info' here to do that automatically)."
127+
128+
info:
129+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
130+
@echo "Running Texinfo files through makeinfo..."
131+
make -C $(BUILDDIR)/texinfo info
132+
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
133+
134+
gettext:
135+
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
136+
@echo
137+
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
138+
139+
changes:
140+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
141+
@echo
142+
@echo "The overview file is in $(BUILDDIR)/changes."
143+
144+
linkcheck:
145+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
146+
@echo
147+
@echo "Link check complete; look for any errors in the above output " \
148+
"or in $(BUILDDIR)/linkcheck/output.txt."
149+
150+
doctest:
151+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
152+
@echo "Testing of doctests in the sources finished, look at the " \
153+
"results in $(BUILDDIR)/doctest/output.txt."

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
Documentation for the PHP Content Repository PHPCR
22

3-
This repository contains the source files. Please visit [phpcr.github.com](http://phpcr.github.com) for a user friendly access to the documentation on PHPCR.
3+
This repository contains the source files. The documentation is hosted on
4+
readthedocs.org: http://phpcr.readthedocs.org/en/latest/
5+
6+
You can also visit the official PHPCR website: phpcr.github.io

_theme/phpcr/layout.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% extends "pyramid/layout.html" %}
2+
{% block extrahead %}
3+
<link rel="stylesheet" href="{{ pathto('_static/phpcr.css', 1) }}" type="text/css" />
4+
{% endblock %}
5+
6+
{% block header %}
7+
{%- if logo %}
8+
<div class="header">
9+
<a href="https://phpcr.github.io">&laquo; Back to PHPCR website</a>
10+
<div class="logo">
11+
<a href="https://phpcr.github.io"><img class="logo" src="{{ pathto('_static/' + logo, 1) }}" alt="Logo"/></a>
12+
</a>
13+
</div>
14+
<div style="clear: both"></div>
15+
</div>
16+
{%- endif %}
17+
{% endblock %}

_theme/phpcr/static/logo_small.png

2.58 KB
Loading

_theme/phpcr/static/phpcr.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
div.header {.
2+
margin: 0;
3+
background: #191818;
4+
background-image: none;
5+
color: #333;
6+
text-align: left;
7+
padding: 10px 10px 10px 10px;
8+
border-bottom: 1px solid #eee;
9+
}
10+
11+
div.logo {
12+
text-align: left;
13+
padding-top: 0px;
14+
}
15+
16+
div.header a {
17+
color: white;
18+
}
19+
20+
div.header .logo {
21+
float: right;
22+
}

_theme/phpcr/theme.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[theme]
2+
inherit = pyramid
3+
stylesheet = pyramid.css
4+
pygments_style = sphinx

book/conclusion.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Conclusion and further reading
2+
==============================
3+
4+
We hope this guide helps to get you started. If you miss anything, have suggestions or questions, please contact us on jackalope-dev@googlegroups.com or #jackalope on irc.freenode.net
5+
6+
Further reading
7+
---------------
8+
9+
Browse through the [API documentation](http://phpcr.github.com/doc/html/index.html) to see what each of the core elements mentioned in the introduction can do.
10+
11+
To fully understand the concepts behind the content repository API, we suggest reading [the Java content repository specification](http://www.day.com/specs/jcr/2.0/index.html) and
12+
then the [simplifications we did for PHP](https://github.com/phpcr/phpcr/blob/master/doc/JCR_TO_PHPCR.txt).

book/getting_started.rst

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
Getting Stated
2+
==============
3+
4+
This aims to provide a rounded general reference to PHPCR. You will mostly see
5+
code examples. It should work with any PHPCR implementation. We propose using
6+
`Jackalope Jackrabbit <https://github.com/jackalope/jackalope-jackrabbit>`_ to
7+
get started as it supports all features described here.
8+
9+
Installing Jackalope
10+
--------------------
11+
12+
Just follow the README of the
13+
`jackalope-jackrabbit <https://github.com/jackalope/jackalope-jackrabbit/blob/master/README.md>`_
14+
repository.
15+
16+
Browser to see what is in the repository
17+
----------------------------------------
18+
19+
There are currently two options for browsing and modifying the contents of the
20+
PHPCR repository.
21+
22+
- `PHPCR Shell <https://github.com/phpcr/phpcr-shell>`_: Aims to provide a full
23+
command line shell interface to PHPCR content repositories. A pre-compiled
24+
PHAR archive is available on the github homepage.
25+
26+
- `Marmelab PHPCR Browser <https://github.com/marmelab/phpcr-browser>`_:
27+
A user-friendly web based PHPCR browser.
28+
29+
The shell is currently more feature complete, but the PHPCR Browser is more
30+
user friendly. We suggest you try both.
31+
32+
In a nutshell
33+
-------------
34+
35+
The shortest self-contained example should output a line with 'value':
36+
37+
.. code-block:: php
38+
39+
<?php
40+
require('/path/to/jackalope-jackrabbit/vendor/autoload.php');
41+
42+
$factoryclass = '\Jackalope\RepositoryFactoryJackrabbit';
43+
$parameters = array('jackalope.jackrabbit_uri' => 'http://localhost:8080/server');
44+
45+
// end of implementation specific configuration
46+
47+
// get a new PHPCR repository instance from the factory class defined above
48+
$factory = new $factoryclass();
49+
$repository = $factory->getRepository($parameters);
50+
51+
// create the credentials object to authenticate with the repository
52+
$credentials = new \PHPCR\SimpleCredentials('admin','admin');
53+
54+
// login to the repository and retrieve the session
55+
$session = $repository->login($credentials, 'default');
56+
57+
// retrieve the root node of the repository ("/")
58+
$root = $session->getRootNode();
59+
60+
// add a new node
61+
$node = $root->addNode('test', 'nt:unstructured');
62+
63+
// set a property on the newly created property
64+
$node->setProperty('prop', 'value');
65+
66+
// save the session, i.e. persist the data
67+
$session->save();
68+
69+
// retrieve the newly created node
70+
$node = $session->getNode('/test');
71+
echo $node->getPropertyValue('prop'); // outputs "value"
72+
73+
74+
Still with us? Good, lets get in a bit deeper...
75+
76+
Get some data into the repository
77+
---------------------------------
78+
79+
We will discuss the import feature in more detail later, but to have some
80+
data, we just import something here. Create an XML file called `test.xml``:
81+
82+
.. code-block:: xml
83+
84+
<data xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0">
85+
<node title="Test" content="This is some test content" />
86+
<sibling title="Test" content="This is another test content">
87+
<child1 title="Child1 title" />
88+
<child2 title="Child2 title" />
89+
<otherchild title="Otherchild title"/>
90+
<yetanother title="Yetanother title">
91+
<child title="Child title" />
92+
</yetanother>
93+
</sibling>
94+
</data>
95+
96+
Now import this into the repository:
97+
98+
.. code-block:: php
99+
100+
<?php
101+
$session->importXML('/', 'test.xml', \PHPCR\ImportUUIDBehaviorInterface::IMPORT_UUID_CREATE_NEW);
102+
$session->save();
103+
104+
You may also use the PHPCR Shell to import data:
105+
106+
.. code-block:: bash
107+
108+
phpcrsh -pmyprofile -c "session:import-xml test.xml"

book/import_export.rst

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Import and export data
2+
======================
3+
4+
As promised, here are some more details on importing and exporting data. There
5+
are two formats:
6+
7+
* The *document view* translates the data into a XML document with node names
8+
as xml elements and properties as attributes and thus very readable. Type
9+
information is lost, and illegal XML characters are encoded.
10+
* The *system view* is a more strict XML document defining the exact structure
11+
of the repository with all type information. However, it is more verbose.
12+
13+
As an analogy, think about an SQL dump file with SQL statements and the dump of
14+
an SQL table into a ``csv`` file. You can restore the data from both, but the SQL
15+
dump knows every detail about your field types and so on while the CSV just
16+
knows the data.
17+
18+
When exporting, you explictly call a method corresponding to the desired
19+
format:
20+
21+
.. code-block:: php
22+
23+
<?php
24+
$file = fopen('/tmp/document.xml', 'w+');
25+
26+
// dump the tree at /foo/bar into a document view file
27+
$session->exportDocumentView(
28+
'/data/sibling',
29+
$file,
30+
true, // skip binary properties to not have large files in the dump
31+
false // recursivly output the child nodes as well
32+
);
33+
34+
fclose($file);
35+
36+
$file = fopen('/tmp/system.xml', 'w+');
37+
// export the tree at /foo/bar into a system view xml file
38+
$session->exportSystemView(
39+
'/data/sibling',
40+
$file,
41+
false, // do not skip binary properties
42+
false
43+
);
44+
45+
fclose($file);
46+
47+
Importing detects the format automatically. If the document is a valid JCR
48+
system view, it is interpreted according to that format, otherwise if it is a
49+
valid XML document it is imported as document:
50+
51+
.. code-block:: php
52+
53+
<?php
54+
$filename = 'dump.xml';
55+
$session->getRootNode()->addNode('imported_data', 'nt:unstructured');
56+
$session->importXML(
57+
'/imported_data', // attach the imported data at this node
58+
$filename,
59+
ImportUUIDBehaviorInterface::IMPORT_UUID_CREATE_NEW
60+
);
61+
62+
When importing nodes with a uuid, a couple of different behaviors can be used:
63+
64+
* ``IMPORT_UUID_CREATE_NEW``: Create new UUIDs for nodes that are imported, so you never get collisions.
65+
* ``IMPORT_UUID_COLLISION_THROW``: Throw an exception if a node with the same UUID already exists.
66+
* ``IMPORT_UUID_COLLISION_REMOVE_EXISTING``: Remove an existing node if an imported node has the same UUID.
67+
* ``IMPORT_UUID_COLLISION_REPLACE_EXISTING``: Replace existing node with the imported node. This can lead to the imported data being put in various places.

0 commit comments

Comments
 (0)