Skip to content

Commit

Permalink
[WIP] docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mbercx committed Nov 21, 2024
1 parent 003dd5c commit 35a667f
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
36 changes: 36 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'qe-tools'
copyright = '2024, Marnik Bercx'
author = 'Marnik Bercx'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"myst_parser",
# "autodoc2",
# "sphinx.ext.intersphinx",
# "sphinx.ext.viewcode",
# "sphinx.ext.autodoc",
# "sphinx.ext.autosummary",
"sphinx_design",
"sphinx_copybutton",
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_book_theme"
html_static_path = ['_static']
16 changes: 16 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Welcome to `qe-tools`'s documentation!

## 💾 Installation

To install the package from the [PyPI](https://pypi.org/), simply use `pip`:

```
pip install qe-tools
```

## 💡 Tutorials

```{toctree}
tutorials/getting_started.md
tutorials/alternatives.md
```
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
49 changes: 49 additions & 0 deletions docs/tutorials/alternatives.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Alternative Design

If you want to parse all the inputs and outputs from a certain directory:

```
from qe_tools.parsers import PwParser
parser = PwParser.from_dir('pw_run')
```

Then you can obtain the outputs as

```
parser.outputs['structure']
```

What if you want to get the `pymatgen` structure?

```
parser.get_outputs(fmt='pymatgen')['structure']
```

## Partial parsing

Let's say you _only_ want to parse the `stdout`.
This could be a use case, i.e. the user wants to get a certain output or input as quickly as possible.

### Using the main `PwParser` class

I would really like there to be a single tool that quickly gives the user access to all `pw.x` parsing functionality.

```
from qe_tools.parsers import PwParser
parser = PwParser.from_stdout('path/to/stdout_file')
```

All methods currently would be:

```
parser = PwParser.from_stdout('path/to/stdout_file')
parser = PwParser.from_xml('path/to/stdout_file')
parser = PwParser.from_crash('path/to/stdout_file')
parser = PwParser.from_input('path/to/stdout_file')
```

```
from qe_tools.outputs import PwOutput
```
14 changes: 14 additions & 0 deletions docs/tutorials/getting_started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Getting started

## Parsing `pw.x` outputs

Say we have just run a `pw.x` calculation in the `qe_dir` directory:

```
from qe_tools.outputs.pw import PwOutput
pw_out = PwOutput.from_dir("qe_dir")
pw_out.outputs
```

> This will now produce a massive amount of output because the whole XML is in there.

0 comments on commit 35a667f

Please sign in to comment.