docurium 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +5 -0
  3. data/LICENCE +19 -0
  4. data/README.md +39 -0
  5. data/TODO.txt +19 -0
  6. data/bin/cm +31 -0
  7. data/docurium.gemspec +25 -0
  8. data/lib/docurium.rb +435 -0
  9. data/lib/docurium/cli.rb +10 -0
  10. data/site/css/style.css +236 -0
  11. data/site/images/search_icon.png +0 -0
  12. data/site/index.html +65 -0
  13. data/site/js/backbone.js +27 -0
  14. data/site/js/docurium.js +649 -0
  15. data/site/js/json2.js +26 -0
  16. data/site/js/underscore.js +26 -0
  17. data/site/shared/css/documentation.css +797 -0
  18. data/site/shared/css/pygments.css +60 -0
  19. data/site/shared/images/active-arrow.png +0 -0
  20. data/site/shared/images/background-v2.png +0 -0
  21. data/site/shared/images/background-white.png +0 -0
  22. data/site/shared/images/dropdown_sprites.jpg +0 -0
  23. data/site/shared/images/footer_logo.png +0 -0
  24. data/site/shared/images/logo.png +0 -0
  25. data/site/shared/images/nav-rule.png +0 -0
  26. data/site/shared/images/next_step_arrow.gif +0 -0
  27. data/site/shared/images/qmark.png +0 -0
  28. data/site/shared/js/documentation.js +43 -0
  29. data/site/shared/js/jquery.js +154 -0
  30. data/test/fixtures/git2/api.docurium +6 -0
  31. data/test/fixtures/git2/blob.h +121 -0
  32. data/test/fixtures/git2/commit.h +302 -0
  33. data/test/fixtures/git2/common.h +98 -0
  34. data/test/fixtures/git2/errors.h +149 -0
  35. data/test/fixtures/git2/index.h +270 -0
  36. data/test/fixtures/git2/object.h +147 -0
  37. data/test/fixtures/git2/odb.h +302 -0
  38. data/test/fixtures/git2/odb_backend.h +107 -0
  39. data/test/fixtures/git2/oid.h +191 -0
  40. data/test/fixtures/git2/refs.h +325 -0
  41. data/test/fixtures/git2/repository.h +217 -0
  42. data/test/fixtures/git2/revwalk.h +187 -0
  43. data/test/fixtures/git2/signature.h +81 -0
  44. data/test/fixtures/git2/tag.h +297 -0
  45. data/test/fixtures/git2/thread-utils.h +71 -0
  46. data/test/fixtures/git2/tree.h +266 -0
  47. data/test/fixtures/git2/types.h +162 -0
  48. data/test/fixtures/git2/zlib.h +58 -0
  49. data/test/repo_test.rb +101 -0
  50. data/test/test_helper.rb +29 -0
  51. metadata +167 -0
@@ -0,0 +1,147 @@
1
+ /*
2
+ * This file is free software; you can redistribute it and/or modify
3
+ * it under the terms of the GNU General Public License, version 2,
4
+ * as published by the Free Software Foundation.
5
+ *
6
+ * In addition to the permissions in the GNU General Public License,
7
+ * the authors give you unlimited permission to link the compiled
8
+ * version of this file into combinations with other programs,
9
+ * and to distribute those combinations without any restriction
10
+ * coming from the use of this file. (The General Public License
11
+ * restrictions do apply in other respects; for example, they cover
12
+ * modification of the file, and distribution when not linked into
13
+ * a combined executable.)
14
+ *
15
+ * This file is distributed in the hope that it will be useful, but
16
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
+ * General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program; see the file COPYING. If not, write to
22
+ * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
23
+ * Boston, MA 02110-1301, USA.
24
+ */
25
+ #ifndef INCLUDE_git_object_h__
26
+ #define INCLUDE_git_object_h__
27
+
28
+ #include "common.h"
29
+ #include "types.h"
30
+ #include "oid.h"
31
+
32
+ /**
33
+ * @file git2/object.h
34
+ * @brief Git revision object management routines
35
+ * @defgroup git_object Git revision object management routines
36
+ * @ingroup Git
37
+ * @{
38
+ */
39
+ GIT_BEGIN_DECL
40
+
41
+ /**
42
+ * Lookup a reference to one of the objects in a repostory.
43
+ *
44
+ * The generated reference is owned by the repository and
45
+ * should be closed with the `git_object_close` method
46
+ * instead of free'd manually.
47
+ *
48
+ * The 'type' parameter must match the type of the object
49
+ * in the odb; the method will fail otherwise.
50
+ * The special value 'GIT_OBJ_ANY' may be passed to let
51
+ * the method guess the object's type.
52
+ *
53
+ * @param object pointer to the looked-up object
54
+ * @param repo the repository to look up the object
55
+ * @param id the unique identifier for the object
56
+ * @param type the type of the object
57
+ * @return a reference to the object
58
+ */
59
+ GIT_EXTERN(int) git_object_lookup(git_object **object, git_repository *repo, const git_oid *id, git_otype type);
60
+
61
+ /**
62
+ * Get the id (SHA1) of a repository object
63
+ *
64
+ * @param obj the repository object
65
+ * @return the SHA1 id
66
+ */
67
+ GIT_EXTERN(const git_oid *) git_object_id(const git_object *obj);
68
+
69
+ /**
70
+ * Get the object type of an object
71
+ *
72
+ * @param obj the repository object
73
+ * @return the object's type
74
+ */
75
+ GIT_EXTERN(git_otype) git_object_type(const git_object *obj);
76
+
77
+ /**
78
+ * Get the repository that owns this object
79
+ *
80
+ * @param obj the object
81
+ * @return the repository who owns this object
82
+ */
83
+ GIT_EXTERN(git_repository *) git_object_owner(const git_object *obj);
84
+
85
+ /**
86
+ * Close an open object
87
+ *
88
+ * This method instructs the library to close an existing
89
+ * object; note that git_objects are owned and cached by the repository
90
+ * so the object may or may not be freed after this library call,
91
+ * depending on how agressive is the caching mechanism used
92
+ * by the repository.
93
+ *
94
+ * IMPORTANT:
95
+ * It *is* necessary to call this method when you stop using
96
+ * an object. Failure to do so will cause a memory leak.
97
+ *
98
+ * @param object the object to close
99
+ */
100
+ GIT_EXTERN(void) git_object_close(git_object *object);
101
+
102
+ /**
103
+ * Convert an object type to it's string representation.
104
+ *
105
+ * The result is a pointer to a string in static memory and
106
+ * should not be free()'ed.
107
+ *
108
+ * @param type object type to convert.
109
+ * @return the corresponding string representation.
110
+ */
111
+ GIT_EXTERN(const char *) git_object_type2string(git_otype type);
112
+
113
+ /**
114
+ * Convert a string object type representation to it's git_otype.
115
+ *
116
+ * @param str the string to convert.
117
+ * @return the corresponding git_otype.
118
+ */
119
+ GIT_EXTERN(git_otype) git_object_string2type(const char *str);
120
+
121
+ /**
122
+ * Determine if the given git_otype is a valid loose object type.
123
+ *
124
+ * @param type object type to test.
125
+ * @return true if the type represents a valid loose object type,
126
+ * false otherwise.
127
+ */
128
+ GIT_EXTERN(int) git_object_typeisloose(git_otype type);
129
+
130
+ /**
131
+ * Get the size in bytes for the structure which
132
+ * acts as an in-memory representation of any given
133
+ * object type.
134
+ *
135
+ * For all the core types, this would the equivalent
136
+ * of calling `sizeof(git_commit)` if the core types
137
+ * were not opaque on the external API.
138
+ *
139
+ * @param type object type to get its size
140
+ * @return size in bytes of the object
141
+ */
142
+ GIT_EXTERN(size_t) git_object__size(git_otype type);
143
+
144
+ /** @} */
145
+ GIT_END_DECL
146
+
147
+ #endif
@@ -0,0 +1,302 @@
1
+ /*
2
+ * This file is free software; you can redistribute it and/or modify
3
+ * it under the terms of the GNU General Public License, version 2,
4
+ * as published by the Free Software Foundation.
5
+ *
6
+ * In addition to the permissions in the GNU General Public License,
7
+ * the authors give you unlimited permission to link the compiled
8
+ * version of this file into combinations with other programs,
9
+ * and to distribute those combinations without any restriction
10
+ * coming from the use of this file. (The General Public License
11
+ * restrictions do apply in other respects; for example, they cover
12
+ * modification of the file, and distribution when not linked into
13
+ * a combined executable.)
14
+ *
15
+ * This file is distributed in the hope that it will be useful, but
16
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
+ * General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program; see the file COPYING. If not, write to
22
+ * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
23
+ * Boston, MA 02110-1301, USA.
24
+ */
25
+ #ifndef INCLUDE_git_odb_h__
26
+ #define INCLUDE_git_odb_h__
27
+
28
+ #include "common.h"
29
+ #include "types.h"
30
+ #include "oid.h"
31
+ #include "odb_backend.h"
32
+
33
+ /**
34
+ * @file git2/odb.h
35
+ * @brief Git object database routines
36
+ * @defgroup git_odb Git object database routines
37
+ * @ingroup Git
38
+ * @{
39
+ */
40
+ GIT_BEGIN_DECL
41
+
42
+ /**
43
+ * Create a new object database with no backends.
44
+ *
45
+ * Before the ODB can be used for read/writing, a custom database
46
+ * backend must be manually added using `git_odb_add_backend()`
47
+ *
48
+ * @param out location to store the database pointer, if opened.
49
+ * Set to NULL if the open failed.
50
+ * @return GIT_SUCCESS if the database was created; otherwise an error
51
+ * code describing why the open was not possible.
52
+ */
53
+ GIT_EXTERN(int) git_odb_new(git_odb **out);
54
+
55
+ /**
56
+ * Create a new object database and automatically add
57
+ * the two default backends:
58
+ *
59
+ * - git_odb_backend_loose: read and write loose object files
60
+ * from disk, assuming `objects_dir` as the Objects folder
61
+ *
62
+ * - git_odb_backend_pack: read objects from packfiles,
63
+ * assuming `objects_dir` as the Objects folder which
64
+ * contains a 'pack/' folder with the corresponding data
65
+ *
66
+ * @param out location to store the database pointer, if opened.
67
+ * Set to NULL if the open failed.
68
+ * @param objects_dir path of the backends' "objects" directory.
69
+ * @return GIT_SUCCESS if the database opened; otherwise an error
70
+ * code describing why the open was not possible.
71
+ */
72
+ GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir);
73
+
74
+ /**
75
+ * Add a custom backend to an existing Object DB
76
+ *
77
+ * Read <odb_backends.h> for more information.
78
+ *
79
+ * @param odb database to add the backend to
80
+ * @paramm backend pointer to a git_odb_backend instance
81
+ * @return 0 on sucess; error code otherwise
82
+ */
83
+ GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority);
84
+
85
+ /**
86
+ * Add a custom backend to an existing Object DB; this
87
+ * backend will work as an alternate.
88
+ *
89
+ * Alternate backends are always checked for objects *after*
90
+ * all the main backends have been exhausted.
91
+ *
92
+ * Writing is disabled on alternate backends.
93
+ *
94
+ * Read <odb_backends.h> for more information.
95
+ *
96
+ * @param odb database to add the backend to
97
+ * @paramm backend pointer to a git_odb_backend instance
98
+ * @return 0 on sucess; error code otherwise
99
+ */
100
+ GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
101
+
102
+ /**
103
+ * Close an open object database.
104
+ *
105
+ * @param db database pointer to close. If NULL no action is taken.
106
+ */
107
+ GIT_EXTERN(void) git_odb_close(git_odb *db);
108
+
109
+ /**
110
+ * Read an object from the database.
111
+ *
112
+ * This method queries all avaiable ODB backends
113
+ * trying to read the given OID.
114
+ *
115
+ * The returned object is reference counted and
116
+ * internally cached, so it should be closed
117
+ * by the user once it's no longer in use.
118
+ *
119
+ * @param out pointer where to store the read object
120
+ * @param db database to search for the object in.
121
+ * @param id identity of the object to read.
122
+ * @return
123
+ * - GIT_SUCCESS if the object was read;
124
+ * - GIT_ENOTFOUND if the object is not in the database.
125
+ */
126
+ GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id);
127
+
128
+ /**
129
+ * Read the header of an object from the database, without
130
+ * reading its full contents.
131
+ *
132
+ * The header includes the length and the type of an object.
133
+ *
134
+ * Note that most backends do not support reading only the header
135
+ * of an object, so the whole object will be read and then the
136
+ * header will be returned.
137
+ *
138
+ * @param len_p pointer where to store the length
139
+ * @param type_p pointer where to store the type
140
+ * @param db database to search for the object in.
141
+ * @param id identity of the object to read.
142
+ * @return
143
+ * - GIT_SUCCESS if the object was read;
144
+ * - GIT_ENOTFOUND if the object is not in the database.
145
+ */
146
+ GIT_EXTERN(int) git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id);
147
+
148
+ /**
149
+ * Determine if the given object can be found in the object database.
150
+ *
151
+ * @param db database to be searched for the given object.
152
+ * @param id the object to search for.
153
+ * @return
154
+ * - 1, if the object was found
155
+ * - 0, otherwise
156
+ */
157
+ GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
158
+
159
+ /**
160
+ * Write an object directly into the ODB
161
+ *
162
+ * This method writes a full object straight into the ODB.
163
+ * For most cases, it is preferred to write objects through a write
164
+ * stream, which is both faster and less memory intensive, specially
165
+ * for big objects.
166
+ *
167
+ * This method is provided for compatibility with custom backends
168
+ * which are not able to support streaming writes
169
+ *
170
+ * @param oid pointer to store the OID result of the write
171
+ * @param odb object database where to store the object
172
+ * @param data buffer with the data to storr
173
+ * @param len size of the buffer
174
+ * @param type type of the data to store
175
+ * @return 0 on success; error code otherwise
176
+ */
177
+ GIT_EXTERN(int) git_odb_write(git_oid *oid, git_odb *odb, const void *data, size_t len, git_otype type);
178
+
179
+ /**
180
+ * Open a stream to write an object into the ODB
181
+ *
182
+ * The type and final length of the object must be specified
183
+ * when opening the stream.
184
+ *
185
+ * The returned stream will be of type `GIT_STREAM_WRONLY` and
186
+ * will have the following methods:
187
+ *
188
+ * - stream->write: write `n` bytes into the stream
189
+ * - stream->finalize_write: close the stream and store the object in
190
+ * the odb
191
+ * - stream->free: free the stream
192
+ *
193
+ * The streaming write won't be effective until `stream->finalize_write`
194
+ * is called and returns without an error
195
+ *
196
+ * The stream must always be free'd or will leak memory.
197
+ *
198
+ * @see git_odb_stream
199
+ *
200
+ * @param stream pointer where to store the stream
201
+ * @param db object database where the stream will write
202
+ * @param size final size of the object that will be written
203
+ * @param type type of the object that will be written
204
+ * @return 0 if the stream was created; error code otherwise
205
+ */
206
+ GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **stream, git_odb *db, size_t size, git_otype type);
207
+
208
+ /**
209
+ * Open a stream to read an object from the ODB
210
+ *
211
+ * Note that most backends do *not* support streaming reads
212
+ * because they store their objects as compressed/delta'ed blobs.
213
+ *
214
+ * It's recommended to use `git_odb_read` instead, which is
215
+ * assured to work on all backends.
216
+ *
217
+ * The returned stream will be of type `GIT_STREAM_RDONLY` and
218
+ * will have the following methods:
219
+ *
220
+ * - stream->read: read `n` bytes from the stream
221
+ * - stream->free: free the stream
222
+ *
223
+ * The stream must always be free'd or will leak memory.
224
+ *
225
+ * @see git_odb_stream
226
+ *
227
+ * @param stream pointer where to store the stream
228
+ * @param db object database where the stream will read from
229
+ * @param oid oid of the object the stream will read from
230
+ * @return 0 if the stream was created; error code otherwise
231
+ */
232
+ GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oid);
233
+
234
+ /**
235
+ * Determine the object-ID (sha1 hash) of a data buffer
236
+ *
237
+ * The resulting SHA-1 OID will the itentifier for the data
238
+ * buffer as if the data buffer it were to written to the ODB.
239
+ *
240
+ * @param id the resulting object-ID.
241
+ * @param data data to hash
242
+ * @param len size of the data
243
+ * @param type of the data to hash
244
+ * @return 0 on success; error code otherwise
245
+ */
246
+ GIT_EXTERN(int) git_odb_hash(git_oid *id, const void *data, size_t len, git_otype type);
247
+
248
+ /**
249
+ * Close an ODB object
250
+ *
251
+ * This method must always be called once a `git_odb_object` is no
252
+ * longer needed, otherwise memory will leak.
253
+ *
254
+ * @param object object to close
255
+ */
256
+ GIT_EXTERN(void) git_odb_object_close(git_odb_object *object);
257
+
258
+ /**
259
+ * Return the OID of an ODB object
260
+ *
261
+ * This is the OID from which the object was read from
262
+ *
263
+ * @param object the object
264
+ * @return a pointer to the OID
265
+ */
266
+ GIT_EXTERN(const git_oid *) git_odb_object_id(git_odb_object *object);
267
+
268
+ /**
269
+ * Return the data of an ODB object
270
+ *
271
+ * This is the uncompressed, raw data as read from the ODB,
272
+ * without the leading header.
273
+ *
274
+ * This pointer is owned by the object and shall not be free'd.
275
+ *
276
+ * @param object the object
277
+ * @return a pointer to the data
278
+ */
279
+ GIT_EXTERN(const void *) git_odb_object_data(git_odb_object *object);
280
+
281
+ /**
282
+ * Return the size of an ODB object
283
+ *
284
+ * This is the real size of the `data` buffer, not the
285
+ * actual size of the object.
286
+ *
287
+ * @param object the object
288
+ * @return the size
289
+ */
290
+ GIT_EXTERN(size_t) git_odb_object_size(git_odb_object *object);
291
+
292
+ /**
293
+ * Return the type of an ODB object
294
+ *
295
+ * @param object the object
296
+ * @return the type
297
+ */
298
+ GIT_EXTERN(git_otype) git_odb_object_type(git_odb_object *object);
299
+
300
+ /** @} */
301
+ GIT_END_DECL
302
+ #endif
@@ -0,0 +1,107 @@
1
+ /*
2
+ * This file is free software; you can redistribute it and/or modify
3
+ * it under the terms of the GNU General Public License, version 2,
4
+ * as published by the Free Software Foundation.
5
+ *
6
+ * In addition to the permissions in the GNU General Public License,
7
+ * the authors give you unlimited permission to link the compiled
8
+ * version of this file into combinations with other programs,
9
+ * and to distribute those combinations without any restriction
10
+ * coming from the use of this file. (The General Public License
11
+ * restrictions do apply in other respects; for example, they cover
12
+ * modification of the file, and distribution when not linked into
13
+ * a combined executable.)
14
+ *
15
+ * This file is distributed in the hope that it will be useful, but
16
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
+ * General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program; see the file COPYING. If not, write to
22
+ * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
23
+ * Boston, MA 02110-1301, USA.
24
+ */
25
+ #ifndef INCLUDE_git_odb_backend_h__
26
+ #define INCLUDE_git_odb_backend_h__
27
+
28
+ #include "common.h"
29
+ #include "types.h"
30
+ #include "oid.h"
31
+
32
+ /**
33
+ * @file git2/backend.h
34
+ * @brief Git custom backend functions
35
+ * @defgroup git_backend Git custom backend API
36
+ * @ingroup Git
37
+ * @{
38
+ */
39
+ GIT_BEGIN_DECL
40
+
41
+ struct git_odb_stream;
42
+
43
+ /** An instance for a custom backend */
44
+ struct git_odb_backend {
45
+ git_odb *odb;
46
+
47
+ int (* read)(
48
+ void **, size_t *, git_otype *,
49
+ struct git_odb_backend *,
50
+ const git_oid *);
51
+
52
+ int (* read_header)(
53
+ size_t *, git_otype *,
54
+ struct git_odb_backend *,
55
+ const git_oid *);
56
+
57
+ int (* write)(
58
+ git_oid *,
59
+ struct git_odb_backend *,
60
+ const void *,
61
+ size_t,
62
+ git_otype);
63
+
64
+ int (* writestream)(
65
+ struct git_odb_stream **,
66
+ struct git_odb_backend *,
67
+ size_t,
68
+ git_otype);
69
+
70
+ int (* readstream)(
71
+ struct git_odb_stream **,
72
+ struct git_odb_backend *,
73
+ const git_oid *);
74
+
75
+ int (* exists)(
76
+ struct git_odb_backend *,
77
+ const git_oid *);
78
+
79
+ void (* free)(struct git_odb_backend *);
80
+ };
81
+
82
+ /** A stream to read/write from a backend */
83
+ struct git_odb_stream {
84
+ struct git_odb_backend *backend;
85
+ int mode;
86
+
87
+ int (*read)(struct git_odb_stream *stream, char *buffer, size_t len);
88
+ int (*write)(struct git_odb_stream *stream, const char *buffer, size_t len);
89
+ int (*finalize_write)(git_oid *oid_p, struct git_odb_stream *stream);
90
+ void (*free)(struct git_odb_stream *stream);
91
+ };
92
+
93
+ /** Streaming mode */
94
+ typedef enum {
95
+ GIT_STREAM_RDONLY = (1 << 1),
96
+ GIT_STREAM_WRONLY = (1 << 2),
97
+ GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY),
98
+ } git_odb_streammode;
99
+
100
+
101
+ GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir);
102
+ GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **backend_out, const char *objects_dir);
103
+ GIT_EXTERN(int) git_odb_backend_sqlite(git_odb_backend **backend_out, const char *sqlite_db);
104
+
105
+ GIT_END_DECL
106
+
107
+ #endif