Skip to content

Commit

Permalink
Se añade carpeta de sphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
jairoruizsaenz committed Feb 18, 2021
1 parent c615781 commit dd2554d
Show file tree
Hide file tree
Showing 19 changed files with 914 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# ignore sphinx folder
sphinx

# ignore testing files
test_reporte.py
perfilamiento_leila.html
Expand Down
20 changes: 20 additions & 0 deletions sphinx/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 = source
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)
35 changes: 35 additions & 0 deletions sphinx/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=source
set BUILDDIR=build

if "%1" == "" goto help

%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.http://sphinx-doc.org/
exit /b 1
)

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

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

:end
popd
34 changes: 34 additions & 0 deletions sphinx/source/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
p {
text-align: justify;
}

li {
text-align: justify;
}

p[class="caption"] {
text-align: center;
}

div[class="wy-menu wy-menu-vertical"] p[class="caption"] {
text-align: left;
}

.wy-nav-content {
max-width: 1200px !important;
}

/* replace the copyright to eliminate the copyright symbol enforced by
the ReadTheDocs theme but eschewed by our legal team */
div[role=contentinfo] {
visibility: hidden;
position: relative;
}

div[role=contentinfo]:after {
visibility: visible;
position: absolute;
top: 0;
left: 0;
content: "Departamento Nacional de Planeación - 2020";
}
Binary file added sphinx/source/_static/image/LEILA.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sphinx/source/_static/image/favicon.ico
Binary file not shown.
Binary file added sphinx/source/_static/image/logo_400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sphinx/source/_static/image/vista_reporte.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions sphinx/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

import os
import sys
# sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath('../../leila'))


# -- Project information -----------------------------------------------------

project = 'LEILA'
copyright = '2020, UCD - DNP'
author = 'UCD - DNP'

# The full version, including alpha/beta/rc tags
release = '0.1'
version = 'v0.1'

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosectionlabel', 'sphinx_copybutton', 'sphinx_multiversion']
# extensions = ['sphinx.ext.autodoc', 'rinoh.frontend.sphinx','sphinx.ext.autosectionlabel', 'sphinx_copybutton']

copybutton_prompt_text = "myinputprompt"
copybutton_prompt_text = ">>> "

# copybutton_prompt_text = r">>> |\.\.\. |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "
# copybutton_prompt_is_regexp = True
# copybutton_only_copy_prompt_lines = False

rinoh_documents = [('index', # top-level file (index.rst)
'Documentacion', # output (target.pdf)
'Documentacion librería calidad de datos', # document title
'DNP - UCD')] # document author

# latex_elements = {'classoptions': ',openany', 'babel': r'\usepackage[english]{babel}'}
latex_elements = {'classoptions': ',openany', 'babel': r'\usepackage[spanish]{babel}'}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'es'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinx_rtd_theme'
html_show_sourcelink = False

html_context = {
"display_github": False, # Integrate GitHub
"github_user": "ucd-dnp", # Username
"github_repo": "leila", # Repo name
"github_version": "master", # Version
"conf_py_path": "/source/", # Path in the checkout to the docs root
}


html_theme_options = {
'display_version': True,
'style_external_links' : True
}


# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_css_files = ['css/custom.css']
html_logo = '_static/image/logo_400.png'
html_favicon = '_static/image/favicon.ico'

from sphinx.writers.html import HTMLTranslator
class PatchedHTMLTranslator(HTMLTranslator):
def visit_reference(self, node):
if node.get('newtab') or not (node.get('target') or node.get('internal') or 'refuri' not in node):
node['target'] = '_blank'
super().visit_reference(node)

def setup(app):
app.set_translator('html', PatchedHTMLTranslator)
29 changes: 29 additions & 0 deletions sphinx/source/ejemplos.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. _ejemplos:

Ejemplos
++++++++

En esta sección se presentan ejemplos de uso de las diferentes funciones de la librería, el código usado y el resultado esperado de estas. Los datos utilizados para los ejemplos corresponden a una muestra de los **Casos positivos de COVID-19 en Colombia** disponibles en el portal de `Datos Abiertos de Colombia`_, se debe aclarar que los datos fueron modificados con el propósito de presentar el alcance de las diferentes funciones de la librería.

.. _Datos Abiertos de Colombia: https://www.datos.gov.co/Salud-y-Protecci-n-Social/Casos-positivos-de-COVID-19-en-Colombia/gt2j-8ykr


.. code-block:: python
>>> # Se importa la librería pandas para la lectura de datos
>>> import pandas as pd
>>> dtypes = {'ID de caso': object,
>>> 'Código DIVIPOLA': object,
>>> 'Codigo departamento': object,
>>> 'Codigo pais':object}
>>> # Lectura de archivo de datos como dataframe
>>> df_datos = pd.read_excel('dataset ejemplos.xlsx', dtype=dtypes)
En caso que desee utilizar los datos utilizados en los ejemplos, puede descargarlos utilizando el siguiente link. :download:`Descargar datos (6.2 MB)<https://planeacionnacional-my.sharepoint.com/:x:/g/personal/ucd_dnp_gov_co/EcSDnonZAlBFqSFZ7N9MP1gBp50GlC_itwgNcLOm9CksyA?Download=1>`.


.. include:: ejemplos/ejemplos_calidad_datos.rst
.. include:: ejemplos/ejemplos_datos_gov.rst
.. include:: ejemplos/ejemplos_reporte.rst
Loading

0 comments on commit dd2554d

Please sign in to comment.