-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Can make real docs now (API and overview).
- Loading branch information
1 parent
6414315
commit 8418184
Showing
17 changed files
with
539 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,96 @@ | ||
# Developer How-To | ||
|
||
To get all of the development dependencies for Python: | ||
|
||
``` | ||
pip install -r layerstack/dev/requirements.txt | ||
``` | ||
|
||
Also, you will need to install | ||
|
||
- [pandoc](https://pandoc.org/installing.html) | ||
|
||
## Create a new release | ||
|
||
- Make the release on github | ||
- Install from github and make sure tests pass | ||
- Create package and push to pypi: | ||
1. Update version number, CHANGES.txt, setup.py, LICENSE and header as needed | ||
2. Run tests locally and fix any issues | ||
3. Install from github and make sure tests pass | ||
4. Uninstall the draft package | ||
5. Publish documentation | ||
6. Create release on github | ||
7. Release tagged version on pypi | ||
|
||
## Publish documentation | ||
|
||
The documentation is built with [Sphinx](http://sphinx-doc.org/index.html). There are several steps to creating and publishing the documentation: | ||
|
||
1. Convert .md input files to .rst | ||
2. Refresh API documentation | ||
3. Build the HTML docs | ||
4. Push to GitHub | ||
|
||
### Markdown to reStructuredText | ||
|
||
Markdown files are registered in `docs/source/md_files.txt`. Paths in that file should be relative to the docs folder and should exclude the file extension. For every file listed there, the `dev/md_to_rst.py` utility will expect to find a markdown (`.md`) file, and will look for an optional `.postfix` file, which is expected to contain `.rst` code to be appended to the `.rst` file created by converting the input `.md` file. Thus, running `dev/md_to_rst.py` on the `doc/source/md_files.txt` file will create revised `.rst` files, one for each entry listed in the registry. In summary: | ||
|
||
``` | ||
cd doc/source | ||
python ../../dev/md_to_rst.py md_files.txt | ||
``` | ||
|
||
### Refresh API Documentation | ||
|
||
- Make sure layerstack is in your PYTHONPATH | ||
- Delete the contents of `source/api`. | ||
- Run `sphinx-apidoc -o source/api ..` from the `doc` folder. | ||
- Compare `source/api/modules.rst` to `source/api.rst`. Delete `setup.rst` and references to it. | ||
- 'git push' changes to the documentation source code as needed. | ||
- Make the documentation per below | ||
|
||
### Building HTML Docs | ||
|
||
Run `make html` for Mac and Linux; `make.bat html` for Windows. | ||
|
||
### Pushing to GitHub Pages | ||
|
||
#### Mac/Linux | ||
|
||
``` | ||
make github | ||
``` | ||
|
||
#### Windows | ||
|
||
``` | ||
make.bat html | ||
``` | ||
|
||
Then run the github-related commands by hand: | ||
|
||
``` | ||
git branch -D gh-pages | ||
git push origin --delete gh-pages | ||
ghp-import -n -b gh-pages -m "Update documentation" ./build/html | ||
git checkout gh-pages | ||
git push origin gh-pages | ||
git checkout master # or whatever branch you were on | ||
``` | ||
|
||
## Release on pypi | ||
|
||
1. [using testpyi](https://packaging.python.org/guides/using-testpypi/) has good instructions for setting up your user account on TestPyPI and PyPI, and configuring twine to know how to access both repositories. | ||
2. Test the package | ||
|
||
``` | ||
python setup.py sdist | ||
twine upload --repository testpypi dist/* | ||
# look at https://test.pypi.org/project/gdxpds/ | ||
pip install --index-url https://test.pypi.org/simple/gdxpds | ||
# check it out ... fix things ... | ||
``` | ||
3. Upload to pypi | ||
``` | ||
twine upload --repository pypi dist/* | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import argparse | ||
import logging | ||
import os | ||
from subprocess import call, list2cmdline | ||
|
||
from layerstack import start_console_log | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
def convert_files(file_registry): | ||
# registry is expected to contain paths relative to its location | ||
base_path = os.path.dirname(file_registry) | ||
|
||
if not os.path.exists(file_registry): | ||
raise ValueError("File registry {} not found".format(file_registry)) | ||
|
||
# loop through registry of md files | ||
with open(file_registry,'r') as registry: | ||
for line in registry: | ||
if line: | ||
# non-empty | ||
p = os.path.join(base_path,line.strip()) | ||
p_md = p + '.md' | ||
if not os.path.exists(p_md): | ||
raise ValueError("There is no {} file.".format(p_md)) | ||
# run pandoc | ||
p_rst = p + '.rst' | ||
try: | ||
cmd_and_args = ['pandoc',p_md,'-o',p_rst] | ||
call(cmd_and_args) | ||
except Exception as e: | ||
try: | ||
call(['pandoc']) | ||
except: | ||
logger.error("Call to pandoc fails") | ||
raise e | ||
if not os.path.exists(p_md): | ||
logger.error("Input file {} does not exist".format(p_md)) | ||
raise e | ||
logger.error("Call '{}' failed".format(list2cmdline(cmd_and_args))) | ||
raise e | ||
# append .postfix | ||
p_postfix = p + '.postfix' | ||
if os.path.exists(p_postfix): | ||
with open(p_rst,'a') as rst: | ||
rst.write("\n") | ||
with open(p_postfix,'r') as postfix: | ||
rst.write(postfix.read()) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="""Utility to convert Markdown | ||
(.md) files to reStructuredText (.rst)""") | ||
parser.add_argument('file_registry',help="""Text file that lists the | ||
markdown files to convert. Each line is the file path and name for an | ||
.md file, where the path is relative to the location of file_registry, | ||
and the .md extension is omitted.""") | ||
parser.add_argument("-d","--debug",action='store_true',default=False, | ||
help="Option to output debug information.") | ||
|
||
args = parser.parse_args() | ||
|
||
# start logging | ||
start_console_log(log_level=logging.DEBUG if args.debug else logging.INFO) | ||
|
||
# perform conversion | ||
convert_files(args.file_registry) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
sphinx | ||
ghp-import | ||
numpydoc | ||
pandoc | ||
pytest | ||
sphinx | ||
sphinx_rtd_theme | ||
twine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
API | ||
### | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
|
||
api/gdxpds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
gdxpds package | ||
============== | ||
|
||
Subpackages | ||
----------- | ||
|
||
.. toctree:: | ||
|
||
gdxpds.test | ||
|
||
Submodules | ||
---------- | ||
|
||
gdxpds.gdx module | ||
----------------- | ||
|
||
.. automodule:: gdxpds.gdx | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
gdxpds.read\_gdx module | ||
----------------------- | ||
|
||
.. automodule:: gdxpds.read_gdx | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
gdxpds.tools module | ||
------------------- | ||
|
||
.. automodule:: gdxpds.tools | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
gdxpds.write\_gdx module | ||
------------------------ | ||
|
||
.. automodule:: gdxpds.write_gdx | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: gdxpds | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Oops, something went wrong.