You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ad...@apache.org on 2016/06/17 23:39:37 UTC

[52/63] [abbrv] incubator-mynewt-site git commit: versioned doc scripts

versioned doc scripts


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/commit/9542ac9d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/tree/9542ac9d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/diff/9542ac9d

Branch: refs/heads/develop
Commit: 9542ac9d37b319a8760f60ccfa55ce01a128e9d0
Parents: e24cc67
Author: Gavin Jefferies <ga...@runtime.io>
Authored: Thu Jun 16 17:23:52 2016 -0700
Committer: Gavin Jefferies <ga...@runtime.io>
Committed: Thu Jun 16 17:23:52 2016 -0700

----------------------------------------------------------------------
 README.md | 35 +++++++++++++++++++++++++++++++++
 build.py  | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 serve.py  | 25 ++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9542ac9d/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..3af40b7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,35 @@
+The Apache MyNewt site is built using [MkDocs](http://www.mkdocs.org/).
+
+## Setup
+### For all contributors:
+* Install MkDocs on your system.
+
+### Additionally for mynewt-site committers:
+* `pip install GitPython`
+* `pip install sh`
+
+## Submitting updates
+
+1. Fork the repo.
+1. Work on the `develop` branch.
+1. Preview your changes using MkDocs.
+    * `mkdocs serve`
+    * visit http://localhost:8000
+1. Submit a pull request.
+
+## Releasing a versioned set of MyNewt documentation
+When a new release of MyNewt occurs, the git `develop` branch of this repository should be in sync with that released version.
+
+### Build
+1. Merge `develop` to `master`.
+1. Switch to the master branch.
+    * `git checkout master`
+1. Create a new _stanza_ in `mkdocs.yml` to reflect the new version.
+    * and update the `latest` flag, only one release should be marked latest.
+1. Commit this change.
+1. Create a branch from master to reflect this new version.
+1. Run: `./build.py`
+
+### Test
+
+### Deploy

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9542ac9d/build.py
----------------------------------------------------------------------
diff --git a/build.py b/build.py
new file mode 100755
index 0000000..e0c4414
--- /dev/null
+++ b/build.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+
+import os
+import click
+import sh
+from git import Repo, Git
+from mkdocs import config
+
+@click.command()
+@click.option('-s', '--site-branch', default='master', help='Use this branch as source for the top level pages')
+@click.option('--dirty', default=False, is_flag=True, help='Allow outstanding modifications in the working directory')
+
+def build(site_branch, dirty):
+
+    # make sure there are no local mods outstanding
+    repo = Repo(os.getcwd())
+    if not dirty and (repo.is_dirty() or repo.untracked_files):
+        print "ERROR: Your working directory has outstanding changes."
+        print "If you are sure this is ok run again with --dirty."
+        return
+
+    mygit = Git(os.getcwd())
+    cfg = config.load_config()
+
+    # sanity check that the version branches exist as named
+    for version in cfg['extra']['versions']:
+        print 'Verifying branch %s' % (version['branch'])
+        mygit.checkout(version['branch'])
+
+    # sanity check - only one latest
+    latest = False
+    for version in cfg['extra']['versions']:
+        if not latest and version['latest']:
+            print 'Latest is %s' % (version['branch'])
+            latest = True
+        elif latest and version['latest']:
+            print 'ERROR: More than one version is latest.'
+            print 'Only one version can be latest: True.'
+            print 'Check mkdocs.yml.'
+            return
+
+    mygit.checkout(site_branch)
+    print "Building the top level site pages (from %s)..." % (site_branch)
+    sh.mkdocs('build', '--clean')
+
+    for version in cfg['extra']['versions']:
+        mygit.checkout(version['branch'])
+        print 'Building docs for: %s...' % (version['branch'])
+        sh.mkdocs('build', '--site-dir', 'site/%s' % (version['branch']))
+        if version['latest']:
+            print 'Building latest...'
+            sh.mkdocs('build', '--site-dir', 'site/latest')
+
+if __name__ == '__main__':
+    repo = Repo(os.getcwd())
+    branch = repo.active_branch
+    mygit = Git(os.getcwd())
+    try:
+        build()
+    finally:
+        mygit.checkout(branch.name)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9542ac9d/serve.py
----------------------------------------------------------------------
diff --git a/serve.py b/serve.py
new file mode 100755
index 0000000..68e8aae
--- /dev/null
+++ b/serve.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import BaseHTTPServer
+from SimpleHTTPServer import SimpleHTTPRequestHandler
+
+os.chdir('site')
+
+HandlerClass = SimpleHTTPRequestHandler
+ServerClass  = BaseHTTPServer.HTTPServer
+Protocol     = "HTTP/1.0"
+
+if sys.argv[1:]:
+    port = int(sys.argv[1])
+else:
+    port = 8000
+server_address = ('127.0.0.1', port)
+
+HandlerClass.protocol_version = Protocol
+httpd = ServerClass(server_address, HandlerClass)
+
+sa = httpd.socket.getsockname()
+print "Serving HTTP on", sa[0], "port", sa[1], "..."
+httpd.serve_forever()