Skip to content

Commit 725297e

Browse files
committed
use code blocks for usage in docstrings
1 parent 9c76b7b commit 725297e

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

libzim/libzim.pyx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -602,12 +602,15 @@ writer_module_doc = """libzim writer module
602602
- Compression to select the algorithm to compress ZIM archive with
603603
604604
Usage:
605+
606+
```python
605607
with Creator(pathlib.Path("myfile.zim")) as creator:
606608
creator.config_verbose(False)
607609
creator.add_metadata("Name", b"my name")
608610
# example
609611
creator.add_item(MyItemSubclass(path, title, mimetype, content)
610-
creator.set_mainpath(path)"""
612+
creator.set_mainpath(path)
613+
```"""
611614
writer_public_objects = [
612615
Creator,
613616
Compression,
@@ -1041,10 +1044,12 @@ reader_module_doc = """libzim reader module
10411044
10421045
Usage:
10431046
1047+
```python
10441048
with Archive(fpath) as zim:
10451049
entry = zim.get_entry_by_path(zim.main_entry.path)
10461050
print(f"Article {entry.title} at {entry.path} is "
1047-
f"{entry.get_item().content.nbytes}b")"""
1051+
f"{entry.get_item().content.nbytes}b")
1052+
```"""
10481053
reader_public_objects = [
10491054
Archive,
10501055
Entry,
@@ -1151,12 +1156,14 @@ search_module_doc = """libzim search module
11511156
11521157
Usage:
11531158
1159+
```python
11541160
archive = libzim.reader.Archive(fpath)
11551161
searcher = Searcher(archive)
11561162
query = Query().set_query("foo")
11571163
search = searcher.search(query)
11581164
for path in search.getResults(10, 10) # get result from 10 to 20 (10 results)
1159-
print(path, archive.get_entry_by_path(path).title)"""
1165+
print(path, archive.get_entry_by_path(path).title)
1166+
```"""
11601167
search_public_objects = [
11611168
Query,
11621169
SearchResultSet,
@@ -1247,16 +1254,17 @@ cdef class SuggestionSearcher:
12471254
return SuggestionSearch.from_search(move(self.c_searcher.suggest(query.encode('UTF-8'))))
12481255

12491256
suggestion_module_doc = """libzim suggestion module
1250-
12511257
- SuggestionSearcher to perform a suggestion search over a libzim.reader.Archive
12521258
12531259
Usage:
12541260
1261+
```python
12551262
archive = Archive(fpath)
12561263
suggestion_searcher = SuggestionSearcher(archive)
12571264
suggestions = suggestion_searcher.suggest("foo")
12581265
for path in suggestion.getResults(10, 10) # get result from 10 to 20 (10 results)
1259-
print(path, archive.get_entry_by_path(path).title)"""
1266+
print(path, archive.get_entry_by_path(path).title)
1267+
```"""
12601268
suggestion_public_objects = [
12611269
SuggestionSearcher
12621270
]
@@ -1268,13 +1276,16 @@ version_module_doc = """libzim version module
12681276
- Get libzim version
12691277
12701278
Usage:
1271-
from libzim.version import get_libzim_version, get_versions, print_versions
1272-
major, minor, patch = get_libzim_version().split(".", 2)
12731279
1274-
for dependency, version in get_versions().items():
1275-
print(f"- {dependency}={version}")
1280+
```python
1281+
from libzim.version import get_libzim_version, get_versions, print_versions
1282+
major, minor, patch = get_libzim_version().split(".", 2)
1283+
1284+
for dependency, version in get_versions().items():
1285+
print(f"- {dependency}={version}")
12761286
1277-
print_versions()"""
1287+
print_versions()
1288+
```"""
12781289

12791290

12801291
def print_versions(out: TextIO = sys.stdout):

0 commit comments

Comments
 (0)