gitinclude¶
sample¶
Sphinx: conf.py¶
extensions = [
"gitinclude",
]
Sample¶
``{gitinclude} HEAD README.md
:language: markdown
:linenos:
``
1 # sphinxcontrib-git_include
2
3 <https://pypi.org/project/gitinclude/>
4
5 `literalinclude` from git repository.
6
7 * using ~~`git cat-file -p {rev}:{path_to_file}`~~
8 * using `git show {rev}:{path_to_file}`
9
10 ## install
11
12 ```
13 > pip install gitinclude
14 ```
15
16 ## Sample
17
18 <https://ousttrue.github.io/sphinxcontrib-gitinclude/>
19
20 ### Sphinx: conf.py
21
22 ```py
23 extensions = [
24 "gitinclude",
25 ]
26 ```
27
28 ### Sphinx: usage
29
30 `myst`
31
32 ```
33 ``{gitinclude} HEAD^ gitinclude/__init__.py
34 :language: python
35 :linenos:
36 ``
37 ```
``{gitinclude} HEAD gitinclude/__init__.py
:language: python
:linenos:
:lines: 109-117
``
1 def read_file(self,
2 filename: str,
3 location: Tuple[str, int] = None) -> List[str]:
4 target = f'{self.rev}:{self.filename}'
5 try:
6 text = subprocess.check_output(['git', 'show', target])
7 if not text:
8 return []
9 text = text.decode('utf-8')