This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating automation code to publish the documentation and the setups
- Loading branch information
Showing
3 changed files
with
170 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
echo off | ||
IF EXIST dist del /Q dist\*.* | ||
|
||
set pythonexe=c:\Python34_x64\python | ||
|
||
|
||
:presentation: | ||
%pythonexe% -u setup.py build_pres | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
%pythonexe% -u setup.py build_pres_2A | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
%pythonexe% -u setup.py build_pres_3A | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
echo ####################################################### | ||
|
||
:documentation: | ||
%pythonexe% -u setup.py build_sphinx | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
echo ####################################################### | ||
|
||
:copyfiles: | ||
if not exist dist\html mkdir dist\html | ||
if not exist dist\html2 mkdir dist\html2 | ||
if not exist dist\html3 mkdir dist\html3 | ||
if not exist dist\latex mkdir dist\latex | ||
if not exist dist\html_pres mkdir dist\html_pres | ||
if not exist dist\html_pres_2A mkdir dist\html_pres_2A | ||
if not exist dist\html_pres_3A mkdir dist\html_pres_3A | ||
|
||
echo #######################################################F | ||
|
||
xcopy /E /C /I /Y _doc\presentation_2A\build\html dist\html_pres_2A | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
xcopy /E /C /I /Y _doc\presentation_3A\build\html dist\html_pres_3A | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
xcopy /E /C /I /Y _doc\presentation\build\html dist\html_pres | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
xcopy /E /C /I /Y _doc\sphinxdoc\build\html dist\html | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
xcopy /E /C /I /Y _doc\sphinxdoc\build2\html dist\html2 | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
xcopy /E /C /I /Y _doc\sphinxdoc\build3\html dist\html3 | ||
if %errorlevel% neq 0 exit /b %errorlevel% | ||
xcopy /E /C /I /Y _doc\sphinxdoc\build\latex dist\latex | ||
if %errorlevel% neq 0 exit /b %errorlevel% |
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,123 @@ | ||
#-*- coding: utf-8 -*- | ||
""" | ||
@file | ||
@brief Helpers to publish the documentation of python to a website | ||
""" | ||
|
||
import os | ||
from pyquickhelper import TransferFTP, FileTreeNode, FolderTransferFTP, open_window_params | ||
from pyquickhelper.filehelper.ftp_transfer_files import content_as_binary | ||
|
||
def trigger_on_specific_strings(content): | ||
""" | ||
look for specific string such as *USERNAME*, *USERDNSDOMAIN*, *HOMEPATH*, *USERNAME*, | ||
*COMPUTERNAME*, *LOGONSERVER*, and returns None if it was found | ||
or modifies the content to remove it | ||
""" | ||
lower_content = content.lower() | ||
for st in ["USERNAME", "USERDNSDOMAIN", "HOMEPATH", "USERNAME", | ||
"COMPUTERNAME", "LOGONSERVER"]: | ||
s = os.environ[st].lower() | ||
if s in lower_content: | ||
return None | ||
return content | ||
|
||
def publish_documentation( | ||
docs, | ||
ftpsite = None, | ||
login = None, | ||
password = None, | ||
key_save = "my_password", | ||
footer_html = None, | ||
content_filter = trigger_on_specific_strings, | ||
is_binary = content_as_binary, | ||
fLOG = print | ||
): | ||
""" | ||
publish the documentation and the setups of a python module on a webiste, | ||
it assumes the modules is organized the same way as | ||
`pyquickhelper <http://www.xavierdupre.fr/app/pyquickhelper/helpsphinx/index.html>`_. | ||
@param docs list of dictionaries (see below) | ||
@param ftpsite something like ``ftp.something.`` | ||
@param login login | ||
@param password password | ||
@param key_save see function `open_window_params <http://www.xavierdupre.fr/app/pyquickhelper/helpsphinx/pyquickhelper/funcwin/frame_params.html#pyquickhelper.funcwin.frame_params.open_window_params>`_ | ||
@param footer_html append this HTML code to any uploaded page (such a javascript code to count the audience) | ||
@param content_filter filter the content of a file (it raises an exception if the result is None), | ||
appies only on text files | ||
@param is_binary a function to tell if a content of a file is binary or not | ||
@param fLOG logging function | ||
*docs* is a list of dictionaries which must contain for each folder | ||
to transfer: | ||
- ``local``: local folder | ||
- ``root_local``: local paths will be related to this root | ||
- ``root_web``: prefix to add to the remote paths | ||
- ``status_file``: a file where the function populates the transfered files and some information about them | ||
A local file is composed by ``<local_root>/<relative_path>``, it | ||
will be uploaded to ``<web_root>/<relative_path>``. | ||
If one of the three first parameters is None, the function | ||
will open a popup windows to ask the missing information. | ||
See `open_window_params <http://www.xavierdupre.fr/app/pyquickhelper/helpsphinx/pyquickhelper/funcwin/frame_params.html#pyquickhelper.funcwin.frame_params.open_window_params>`_. | ||
""" | ||
|
||
params = {"ftpsite":ftpsite, | ||
"login":login, | ||
"password":password, | ||
} | ||
|
||
nbnone = len ( [ v for k,v in params.items() if v is None or len(v) == 0 ] ) | ||
if nbnone > 0: | ||
params = open_window_params (params, title="Website and Credentials", help_string = "ftp site + login + password", key_save=key_save) | ||
|
||
nbnone = [ v for k,v in params.items() if v is None or len(v) == 0 ] | ||
if len(nbnone) > 0: | ||
raise Exception("one of the parameters is None:\n" + str(nbnone)) | ||
|
||
password = params["password"] | ||
login = params["login"] | ||
ftpsite = params["ftpsite"] | ||
|
||
ftp = TransferFTP(ftpsite, | ||
login, | ||
password, | ||
fLOG=fLOG) | ||
|
||
for project in docs: | ||
|
||
location = project["local"] | ||
root_local = project["root_local"] | ||
root_web = project["root_web"] | ||
|
||
fLOG("-------------------------",location) | ||
|
||
sfile = project["status_file"] | ||
rootw = project["root_web"] | ||
|
||
ftn = FileTreeNode(root_local) | ||
fftp = FolderTransferFTP (ftn, ftp, sfile, | ||
root_web = rootw, | ||
fLOG=fLOG, | ||
footer_html = footer_html, | ||
content_filter=content_filter, | ||
is_binary=is_binary) | ||
|
||
fftp.start_transfering() | ||
|
||
ftn = FileTreeNode(os.path.join(root_local,".."), | ||
filter = lambda root, path, f, dir: not dir) | ||
fftp = FolderTransferFTP (ftn, ftp, sfile, | ||
root_web = root_web.replace("helpsphinx",""), | ||
fLOG=fLOG, | ||
footer_html = footer_html, | ||
content_filter=content_filter, | ||
is_binary=is_binary) | ||
|
||
fftp.start_transfering() | ||
|
||
|
||
ftp.close() | ||
|
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