Merge lp:~james-w/pkgme/add-docs into lp:pkgme

Proposed by James Westby
Status: Merged
Approved by: Barry Warsaw
Approved revision: 43
Merged at revision: 46
Proposed branch: lp:~james-w/pkgme/add-docs
Merge into: lp:pkgme
Diff against target: 151 lines (+78/-17)
1 file modified
doc/backends/index.txt (+78/-17)
To merge this branch: bzr merge lp:~james-w/pkgme/add-docs
Reviewer Review Type Date Requested Status
Barry Warsaw (community) Approve
Review via email: mp+44633@code.launchpad.net

Description of the change

Hi,

Here are some improvements to the docs for backend authors,
notably trying to explain how to implement a backend.

Thanks,

James

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Any chance of a review of this one too? Pretty please? :-)

Thanks,

James

Revision history for this message
Barry Warsaw (barry) wrote :
Download full text (3.4 KiB)

=== modified file 'doc/backends/index.txt'
--- doc/backends/index.txt 2010-12-15 02:14:16 +0000
+++ doc/backends/index.txt 2010-12-23 23:56:44 +0000
> @@ -97,11 +97,71 @@
> Implementing a backend
> ----------------------
>
> -.. FIXME: Explain how to implement a backend
> -
> -
> -Information that pkgme may request
> -----------------------------------
> +A backend is a directory of scripts that are called by ``pkgme`` as needed.
> +
> +The name of the directory is the name of the backend, and should be unique.
> +
> +The first script that you need to provide is called ``want``, and is called to decide
> +if your backend should be used for the project in question. It is executed with the
> +current directory the root of the project, and should return a number on stdout that is
> +how well the backend will work for the project (see `Selecting a backend`_).
> +
> +After implementing that script you have a choice of how to provide the rest of the
> +information.
> +
> +Many scripts
> +~~~~~~~~~~~~
> +
> +You can provide one script per piece of information that ``pkgme`` may request.
> +The script is given the name of the piece of information that it will provide, and
> +is expected to print the information on stdout when invoked.

Do you have a list of the specific pieces of information that pkgme may
request? Maybe either enumerate them here or provide a cross-ref to the
page where they are defined.

> +
> +Each script may exit with an error if the information cannot be provided.
> +
> +The scripts are called with a current working directory of the root of the project,
> +and so should examine the files in the working directory to obtain the information.
> +
> +One script
> +~~~~~~~~~~
> +
> +It is also possible to write a single script that can provide multiple bits of
> +information at once. This script reads in JSON formatted description of the pieces
> +of information that are needed, and then writes a JSON formatted response on stdout
> +that contains the pieces of information.
> +
> +The script can exit with an error if no information can be provided, or may choose
> +to respond omitting the information that cannot be provided.
> +
> +The scripts is called with a current working directory of the root of the project,

s/scripts is/script is/

> +and so should examine the files in the working directory to obtain the information.
> +
> +The script may be called multiple times for the same project.
> +
> +The script should be called ``all_info``.
> +
> +``pkgme`` will write a JSON formatted list on the stdin of the ``all_info`` script
> +containing the names of the pieces of information that are desired. It is expected
> +to write a JSON formatted dict to its stdout and then exit. The dict should have keys
> +that are the names passed in to the script, and the values should be the required
> +information.
> +
> +For instance, if the script is passed::
> +
> + ["package_name", "version"]
> +
> +then it should respond with something like::
> +
> + {
> + "package_name": "foo",
> + "version": 1.0
> + }
> +
> +Keys may be omitted from the output if the information cannot be provided.
> +
> +Information that ``pkgme`` may request
> +---...

Read more...

review: Approve
Revision history for this message
Barry Warsaw (barry) wrote :

Approved, with a few minor comments.

Revision history for this message
James Westby (james-w) wrote :

On Mon, 24 Jan 2011 21:03:54 -0000, Barry Warsaw <email address hidden> wrote:
> Do you have a list of the specific pieces of information that pkgme may
> request? Maybe either enumerate them here or provide a cross-ref to the
> page where they are defined.

A forward reference is a good idea.

> > +The scripts is called with a current working directory of the root of the project,
>
> s/scripts is/script is/

Thanks.

James

lp:~james-w/pkgme/add-docs updated
44. By James Westby

Tweaks from review. Thanks Barry.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'doc/backends/index.txt'
2--- doc/backends/index.txt 2010-12-15 02:14:16 +0000
3+++ doc/backends/index.txt 2011-02-05 21:06:31 +0000
4@@ -1,8 +1,8 @@
5-==============
6-pkgme backends
7-==============
8+==================
9+``pkgme`` backends
10+==================
11
12-pkgme backends provide the project specific information that is needed to generate
13+``pkgme`` backends provide the project specific information that is needed to generate
14 the packaging. They examine the project in question and provide the information to
15 the best of their ability.
16
17@@ -13,7 +13,7 @@
18 How they work
19 -------------
20
21-pkgme itself is agnostic about the type of project that it is working on, but knows
22+``pkgme`` itself is agnostic about the type of project that it is working on, but knows
23 how to put information about a project in to the packaging files such that result
24 should work, assuming that the information provided is good enough.
25
26@@ -22,13 +22,13 @@
27 project.
28
29 In this manner, the backends, and so you as a backend author, don't need to know
30-much about packaging, and pkgme doesn't need to know about every different sort of
31+much about packaging, and ``pkgme`` doesn't need to know about every different sort of
32 project that there is.
33
34 Selecting a backend
35 -------------------
36
37-When pkgme is asked to create the packaging for a project, it firsts selects the
38+When ``pkgme`` is asked to create the packaging for a project, it firsts selects the
39 backend that is most suited to the task. To do this it asks each backend to report
40 a score of how well it thinks that it can handle that project.
41
42@@ -59,7 +59,7 @@
43 Getting the info
44 ----------------
45
46-When pkgme needs to get a bit of information about the project, such as its name, or
47+When ``pkgme`` needs to get a bit of information about the project, such as its name, or
48 the dependencies required to build, it asks the backend that it selected. The backend
49 is expected to do its best to provide that information, but not to provide it if it can't
50 do so, otherwise the generated packaging wouldn't work.
51@@ -74,18 +74,18 @@
52
53 The first of these is in the specification of the build dependencies, where the backend
54 has to provide the list of packages that are needed. While the backend probably has
55-available the list of modules used or similar, it wouldn't be possible for pkgme to
56+available the list of modules used or similar, it wouldn't be possible for ``pkgme`` to
57 translate these to a list of packages while remaining generic.
58
59 Therefore one of the things the backend must be able to do is to go from the list of
60 modules to the list of packages that provide them, using whatever means is appropriate.
61
62 The second area where the backend needs to know something related to packaging is specifying
63-what build system to use. pkgme leaves all the steps of actually building the package, knowing
64+what build system to use. ``pkgme`` leaves all the steps of actually building the package, knowing
65 what commands to run to build, what files to put where, up to debhelper. debhelper in turn
66-delegates some of this work to its buildsystems, which are analogous to pkgme's backends.
67+delegates some of this work to its buildsystems, which are analogous to ``pkgme``'s backends.
68
69-Therefore pkgme needs to know which buildsystem to instruct debhelper to use, and for this it
70+Therefore ``pkgme`` needs to know which buildsystem to instruct debhelper to use, and for this it
71 will query the backend. This means that the backend should know which debhelper buildsystem
72 is appropriate for the project. If you are implementing a backend for which there isn't yet
73 a debhelper buildsystem, you will also have to implement that in order to enjoy completely
74@@ -97,11 +97,72 @@
75 Implementing a backend
76 ----------------------
77
78-.. FIXME: Explain how to implement a backend
79-
80-
81-Information that pkgme may request
82-----------------------------------
83+A backend is a directory of scripts that are called by ``pkgme`` as needed.
84+
85+The name of the directory is the name of the backend, and should be unique.
86+
87+The first script that you need to provide is called ``want``, and is called to decide
88+if your backend should be used for the project in question. It is executed with the
89+current directory the root of the project, and should return a number on stdout that is
90+how well the backend will work for the project (see `Selecting a backend`_).
91+
92+After implementing that script you have a choice of how to provide the rest of the
93+information.
94+
95+Many scripts
96+~~~~~~~~~~~~
97+
98+You can provide one script per piece of information that ``pkgme`` may request.
99+The script is given the name of the piece of information that it will provide, and
100+is expected to print the information on stdout when invoked. See
101+`Information that ``pkgme`` may request`_.
102+
103+Each script may exit with an error if the information cannot be provided.
104+
105+The scripts are called with a current working directory of the root of the project,
106+and so should examine the files in the working directory to obtain the information.
107+
108+One script
109+~~~~~~~~~~
110+
111+It is also possible to write a single script that can provide multiple bits of
112+information at once. This script reads in JSON formatted description of the pieces
113+of information that are needed, and then writes a JSON formatted response on stdout
114+that contains the pieces of information.
115+
116+The script can exit with an error if no information can be provided, or may choose
117+to respond omitting the information that cannot be provided.
118+
119+The script is called with a current working directory of the root of the project,
120+and so should examine the files in the working directory to obtain the information.
121+
122+The script may be called multiple times for the same project.
123+
124+The script should be called ``all_info``.
125+
126+``pkgme`` will write a JSON formatted list on the stdin of the ``all_info`` script
127+containing the names of the pieces of information that are desired. It is expected
128+to write a JSON formatted dict to its stdout and then exit. The dict should have keys
129+that are the names passed in to the script, and the values should be the required
130+information.
131+
132+For instance, if the script is passed::
133+
134+ ["package_name", "version"]
135+
136+then it should respond with something like::
137+
138+ {
139+ "package_name": "foo",
140+ "version": 1.0
141+ }
142+
143+Keys may be omitted from the output if the information cannot be provided.
144+
145+Information that ``pkgme`` may request
146+--------------------------------------
147+
148+The following are the bits of information that your backend may be requested to provide.
149
150 .. This outputs information on the info that a backend can provide, based
151 on introspecting the code. See pkgme.rstinfo for the code that does

Subscribers

People subscribed via source and target branches

to all changes: