Skip to content

Sphinx support (WIP) #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3bf7d42
feat: xml to json conversion
ClimenteA Mar 11, 2024
321fa35
feat: pass down section attrs to title
ClimenteA Mar 11, 2024
1b6acd9
wip: parsing xml
ClimenteA Mar 12, 2024
ac09eec
feat: cleanups, more xml tags parsed, figure out header level based o…
ClimenteA Mar 13, 2024
7bedf59
feat: xml table to html
ClimenteA Mar 13, 2024
8dc7b48
feat: handle case when code is ipython3
ClimenteA Mar 14, 2024
a9bdfbe
fix: updated regex to include attrs on match
ClimenteA Mar 14, 2024
23f9499
wip: trying to parse api xml docs
ClimenteA Mar 14, 2024
445faa1
feat: parse func/class param list
ClimenteA Mar 15, 2024
cf3da0b
chore: added back ignored tags line
ClimenteA Mar 15, 2024
c8b7817
feat: parse doc returns
ClimenteA Mar 15, 2024
74cc875
feat: parseDefault xmlstr
ClimenteA Mar 15, 2024
aa915bf
chore: nestedtagMapp
ClimenteA Mar 15, 2024
c8db058
feat: handle xml with ipynb references
ClimenteA Mar 15, 2024
e6aa0c1
feat: more mapped tags, unified ipynb+xml wip
ClimenteA Mar 18, 2024
84ca990
feat: handle base64 images from notebook
ClimenteA Mar 18, 2024
26c61b7
fix: handle tage emphasis
ClimenteA Mar 18, 2024
3a58c83
chore: merge main
ClimenteA Mar 18, 2024
98aad17
feat: sphinx api docs wip
ClimenteA Mar 19, 2024
7666ffc
feat: updated sphinx docs
ClimenteA Mar 19, 2024
df13444
chore: typo in readme
ClimenteA Mar 19, 2024
833326b
chore: updated docs
ClimenteA Mar 20, 2024
6ca9e1f
feat: gather all parsed data in one parsable list which can be conver…
ClimenteA Mar 20, 2024
41ab086
feat: started working on ejs sphinx template
ClimenteA Mar 20, 2024
224e147
feat: modified postdoc init to handle sphinx-python docs initialization
ClimenteA Mar 20, 2024
5f1abbd
chore: updated sphinx docs in reame
ClimenteA Mar 21, 2024
1639db3
feat: group parsed data
ClimenteA Mar 21, 2024
27b1bf8
feat: attention and note blocks handling
ClimenteA Mar 21, 2024
76f34d0
feat: handle references to local images
ClimenteA Mar 21, 2024
29401e8
feat: handle html,css object snippet from ipynb
ClimenteA Mar 21, 2024
daf059f
chore: todo next parse table to html
ClimenteA Mar 21, 2024
40adbd6
fix: pass down source sphinx dir to extract images
ClimenteA Mar 22, 2024
c264bd7
chore: get innerHTMl for all elements
ClimenteA Mar 22, 2024
5d8c5e1
feat: parse table
ClimenteA Mar 22, 2024
30d9a1e
feat: handle raw undeeded data
ClimenteA Mar 22, 2024
5413903
feat: parse formulas with katex and node
ClimenteA Mar 22, 2024
a4eddc0
feat: handle figure with image
ClimenteA Mar 22, 2024
13ef4fb
feat: mermaid and lable handling
ClimenteA Mar 25, 2024
13f38a0
feat: better parse func/class signature
ClimenteA Mar 25, 2024
90172ae
feat: better desc returns
ClimenteA Mar 25, 2024
1e3cc1d
feat: parse definition list params
ClimenteA Mar 25, 2024
f9256d6
feat: handle doctest block
ClimenteA Mar 25, 2024
2322500
feat: passed thru all echopype xml files - output pretty good
ClimenteA Mar 25, 2024
3e713db
feat: generate html files from xml sphinx output sphinx build xml
ClimenteA Mar 26, 2024
80084fc
chore: removed test folders from .gitignore
ClimenteA Mar 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,67 @@ Having trouble? Get help in the [Discussions](https://github.com/PostDocJS/postd
## Links

- [License (MIT)](LICENSE)
- [Website](https://postdoc.dev)
- [Website](https://postdoc.dev)


## Sphinx documentation

Postdoc can handle sphinx documentation as well.

In your python project repository directory run the following CLI command:

```shell
sphinx-build -M xml ./docs/source ./docs/build/ -W --keep-going
```

**Important**: You sould be able to generate sphinx docs before running `postdoc init` command.

On `postdoc init` command to handle the sphinx docs select the `sphinx-python` template and paste path to sphinx docs folder (where you have the Makefile and source folder).

```
? Select the UI template to used: sphinx-python
? Enter path to python sphinx docs: absolute/path/to/sphinx/docs
```

**Something went wrong?**

In case `sphinx-build` command failed, make sure the following applies to your python project as well.

Usually, setup for sphinx documentation has the following directory structure:

```

/docs: Main directory for Sphinx documentation. <---- we need this path!
/source: Your sphinx configuration and documentation in .md, .rst files.
conf.py: Config file for Sphinx
index.rst: Entrypoint for Sphinx docs (main page)
modules.rst: Lists the modules of your Python package.
/build: The output directory where Sphinx saves the generated documentation.
Makefile: A file with commands to build the docs in various formats.

/your_python_package: The directory containing your Python package code.
__init__.py: Indicates that this directory is a Python package.
module1.py: A module in your package.
module2.py: Another module in your package.
setup.py: The setup script for installing the package.

```

TIP: If you get some imports errors make sure in the `conf.py` you added this code at the top:

```py
# conf.py

import sys

absPathToPyPackage = __file__.split("docs")[0]

sys.path.append(absPathToPyPackage)

```

With that change sphinx will be able to get doc strings from python classes and functions.




2 changes: 1 addition & 1 deletion extra/templates/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"nightwatch": "${nightwatch_version}",
"nightwatch-plugin-postdoc": "${nightwatch_plugin_postdoc_version}"
}
}
}
4 changes: 3 additions & 1 deletion extra/templates/default/postdoc.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {sep} from 'node:path';
import { sep } from 'node:path';

export default {
template: 'default',

pwa: {
enabled: false
},
Expand Down
17 changes: 17 additions & 0 deletions extra/templates/sphinx-python/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "${project_name}",
"type": "module",
"version": "0.0.1",
"private": true,
"scripts": {
"test": "postdoc test",
"start": "postdoc run",
"build": "postdoc build",
"preview": "postdoc preview"
},
"devDependencies": {
"postdoc": "${postdoc_version}",
"nightwatch": "${nightwatch_version}",
"nightwatch-plugin-postdoc": "${nightwatch_plugin_postdoc_version}"
}
}
58 changes: 58 additions & 0 deletions extra/templates/sphinx-python/postdoc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { sep } from 'node:path';

export default {
template: 'sphinx-python',
sphinx_docs_path: "${sphinx_docs_path}",

pwa: {
enabled: false
},

directories: {
content: './content',
tests: './test',
output: './out',
layouts: './src/layouts',
includes: './src/includes'
},

apidocs: {
tags: {},
source: null,
layout: 'apidocs.ejs',

createUrl(filePath) {
return filePath.split(sep).join('/').replace(/\.js$/, '.html');
}
},

ignore: {
pages: [],
apidocs: [],
layouts: []
},

logger: {
quiet: false,
noColors: false
},

nightwatch: {
headless: true,
browser: 'chrome',
watch: false,
parallel: false
},

appSettings: {},

markdown: {
extensions: [],
shikiOptions: {}
},

vite: {
publicDir: './src/public',
logLevel: 'silent'
}
};
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/code_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/facebook_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/github_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/instagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/instagram_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/light_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions extra/templates/sphinx-python/src/assets/lightbulb_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/logo_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/moon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extra/templates/sphinx-python/src/assets/search_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading