Skip to content

Commit 7ef04a6

Browse files
authored
Adding Sphinx Output to CI (Azure#7561)
* support for single package site gen using tox. tox -e sphinx * updating manifest files to include tests in the source distribution. this means that the examples will also be renderable on docs.ms * Added steps to CI to generate documentation for targeted servicedirectory
1 parent 2e8d07a commit 7ef04a6

File tree

21 files changed

+821
-14
lines changed

21 files changed

+821
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ bin/
2020
obj/
2121
dist/
2222
MANIFEST
23+
_docs
2324

2425
# Result of running python setup.py install/pip install -e
2526
RECORD.txt

doc/sphinx/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,3 @@
262262

263263
# If false, no module index is generated.
264264
#latex_domain_indices = True
265-
266-

doc/sphinx/generate_doc.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import logging
33
import json
44
from pathlib import Path
5+
import os
56

6-
CONFIG_FILE = './package_service_mapping.json'
7+
CONFIG_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), './package_service_mapping.json')
78
GENERATED_PACKAGES_LIST_FILE = 'autorest_generated_packages.rst'
89

910
_LOGGER = logging.getLogger(__name__)
@@ -83,14 +84,15 @@ def make_title(title):
8384
"azure.mgmt.resource.subscriptions",
8485
]
8586

86-
def generate_doc(config_path, project_pattern=None):
87-
87+
def generate_doc(config_path, output_directory = "./ref/", project_pattern=None):
8888
multiapi_found_apiversion = {}
8989

90+
rst_path_template = os.path.join(output_directory, '{}.rst')
91+
rst_namespace_template = os.path.join(output_directory, '{}.{}.rst')
92+
9093
with Path(config_path).open() as config_fd:
9194
config = json.load(config_fd)
9295
package_list_path = []
93-
rst_path_template = './ref/{}.rst'
9496

9597
namespaces = [n for pack in config.values() for n in pack.get("namespaces", {})]
9698

@@ -109,7 +111,7 @@ def generate_doc(config_path, project_pattern=None):
109111
))
110112

111113
for module in ["operations", "models"]:
112-
with Path('./ref/{}.{}.rst'.format(namespace, module)).open('w') as rst_file:
114+
with Path(rst_namespace_template.format(namespace, module)).open('w') as rst_file:
113115
rst_file.write(SUBMODULE_TEMPLATE.format(
114116
title=make_title(namespace+"."+module+" module"),
115117
namespace=namespace,
@@ -167,6 +169,9 @@ def main():
167169
parser.add_argument("--debug",
168170
dest="debug", action="store_true",
169171
help="Verbosity in DEBUG mode")
172+
parser.add_argument("--out", "-o",
173+
dest="output_directory",
174+
help="The final resting place for the generated sphinx source files.")
170175

171176
args = parser.parse_args()
172177

@@ -175,7 +180,7 @@ def main():
175180
logging.basicConfig()
176181
main_logger.setLevel(logging.DEBUG if args.debug else logging.INFO)
177182

178-
generate_doc(args.config_path, args.project)
183+
generate_doc(args.config_path, args.output_directory, args.project)
179184

180185
if __name__ == "__main__":
181186
main()

doc/sphinx/individual_build_conf.py

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# azure-sdk-for-python documentation build configuration file, created by
4+
# sphinx-quickstart on Fri Jun 27 15:42:45 2014.
5+
#
6+
# This file is execfile()d with the current directory set to its
7+
# containing dir.
8+
#
9+
# Note that not all possible configuration values are present in this
10+
# autogenerated file.
11+
#
12+
# All configuration values have a default; values that are commented out
13+
# serve to show the default.
14+
15+
import sys
16+
import os
17+
import sphinx_rtd_theme
18+
19+
# If extensions (or modules to document with autodoc) are in another directory,
20+
# add these directories to sys.path here. If the directory is relative to the
21+
# documentation root, use os.path.abspath to make it absolute, like shown here.
22+
# sys.path.insert(0, os.path.abspath('.'))
23+
24+
# FIX FOR EXAMPLE REFERENCES
25+
# REPO_ROOT = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', '..', '..'))
26+
# examples_tests_glob_expansion = os.path.join(REPO_ROOT, 'sdk/*/*/examples/**/test*example*.py')
27+
# samples_glob_expansion = os.path.join(REPO_ROOT, 'sdk/*/*/tests/**/test*sample*.py')
28+
# test_examples_glob_expansion = os.path.join(REPO_ROOT, 'sdk/*/*/tests/**/test*example*.py')
29+
30+
# example_tests_files = glob.glob(examples_tests_glob_expansion, recursive=True)
31+
# test_examples_files = glob.glob(test_examples_glob_expansion, recursive=True)
32+
# samples_files = glob.glob(samples_glob_expansion, recursive=True)
33+
34+
# all_files = [os.path.relpath(file, REPO_ROOT) for file in list(set(example_tests_files + test_examples_files + samples_files))]
35+
36+
# # now for each package, we need to copy it and write it to the relative path FROM THE CURRENT CWD
37+
# for example_file in all_files:
38+
# relative_path_in_pkg = os.path.join(*(example_file.split(os.path.sep)[3:]))
39+
# final_destination = os.path.abspath(os.path.join(os.path.dirname(__file__), relative_path_in_pkg))
40+
41+
# # create the directories if they don't already exist
42+
# os.makedirs(os.path.dirname(final_destination), exist_ok=True)
43+
44+
# # finally copy the example file into the sphinx folder
45+
# copyfile(os.path.join(REPO_ROOT, example_file), final_destination)
46+
47+
# -- General configuration ------------------------------------------------
48+
49+
# If your documentation needs a minimal Sphinx version, state it here.
50+
#needs_sphinx = '1.0'
51+
52+
# Add any Sphinx extension module names here, as strings. They can be
53+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
54+
# ones.
55+
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.doctest',
56+
'sphinx.ext.viewcode', 'sphinx.ext.intersphinx', 'sphinx.ext.napoleon']
57+
58+
intersphinx_mapping = {
59+
'python': ('https://docs.python.org/3.5', None),
60+
'msrestazure': ('http://msrestazure.readthedocs.io/en/latest/', None),
61+
'msrest': ('http://msrest.readthedocs.io/en/latest/', None)
62+
}
63+
64+
# Add any paths that contain templates here, relative to this directory.
65+
templates_path = ['_templates']
66+
67+
source_parsers = {
68+
'.md': 'recommonmark.parser.CommonMarkParser',
69+
}
70+
71+
# The suffix of source filenames.
72+
source_suffix = ['.rst', '.md']
73+
74+
# The encoding of source files.
75+
#source_encoding = 'utf-8-sig'
76+
77+
# The master toctree document.
78+
master_doc = 'index'
79+
80+
# General information about the project.
81+
project = u'Azure SDK for Python'
82+
copyright = u'2019, Microsoft'
83+
84+
# The version info for the project you're documenting, acts as replacement for
85+
# |version| and |release|, also used in various other places throughout the
86+
# built documents.
87+
#
88+
# The short X.Y version.
89+
version = '2.0.0'
90+
# The full version, including alpha/beta/rc tags.
91+
release = '2.0.0'
92+
93+
# The language for content autogenerated by Sphinx. Refer to documentation
94+
# for a list of supported languages.
95+
#language = None
96+
97+
# There are two options for replacing |today|: either, you set today to some
98+
# non-false value, then it is used:
99+
#today = ''
100+
# Else, today_fmt is used as the format for a strftime call.
101+
#today_fmt = '%B %d, %Y'
102+
103+
# List of patterns, relative to source directory, that match files and
104+
# directories to ignore when looking for source files.
105+
exclude_patterns = ['_build']
106+
107+
# The reST default role (used for this markup: `text`) to use for all
108+
# documents.
109+
#default_role = None
110+
111+
# If true, '()' will be appended to :func: etc. cross-reference text.
112+
#add_function_parentheses = True
113+
114+
# If true, the current module name will be prepended to all description
115+
# unit titles (such as .. function::).
116+
#add_module_names = True
117+
118+
# If true, sectionauthor and moduleauthor directives will be shown in the
119+
# output. They are ignored by default.
120+
#show_authors = False
121+
122+
# The name of the Pygments (syntax highlighting) style to use.
123+
pygments_style = 'sphinx'
124+
125+
# A list of ignored prefixes for module index sorting.
126+
#modindex_common_prefix = []
127+
128+
# If true, keep warnings as "system message" paragraphs in the built documents.
129+
#keep_warnings = False
130+
131+
# -- Options for extensions ----------------------------------------------------
132+
autoclass_content = 'both'
133+
134+
# -- Options for HTML output ----------------------------------------------
135+
136+
# The theme to use for HTML and HTML Help pages. See the documentation for
137+
# a list of builtin themes.
138+
html_theme = 'sphinx_rtd_theme'
139+
#html_theme_options = {'collapsiblesidebar': True}
140+
141+
# Activate the theme.
142+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
143+
144+
# Theme options are theme-specific and customize the look and feel of a theme
145+
# further. For a list of options available for each theme, see the
146+
# documentation.
147+
#html_theme_options = {}
148+
149+
# Add any paths that contain custom themes here, relative to this directory.
150+
#html_theme_path = []
151+
152+
# The name for this set of Sphinx documents. If None, it defaults to
153+
# "<project> v<release> documentation".
154+
#html_title = None
155+
156+
# A shorter title for the navigation bar. Default is the same as html_title.
157+
#html_short_title = None
158+
159+
# The name of an image file (relative to this directory) to place at the top
160+
# of the sidebar.
161+
#html_logo = None
162+
163+
# The name of an image file (within the static path) to use as favicon of the
164+
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
165+
# pixels large.
166+
#html_favicon = None
167+
168+
# Add any paths that contain custom static files (such as style sheets) here,
169+
# relative to this directory. They are copied after the builtin static files,
170+
# so a file named "default.css" will overwrite the builtin "default.css".
171+
# html_static_path = ['_static']
172+
173+
# Add any extra paths that contain custom files (such as robots.txt or
174+
# .htaccess) here, relative to this directory. These files are copied
175+
# directly to the root of the documentation.
176+
#html_extra_path = []
177+
178+
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
179+
# using the given strftime format.
180+
#html_last_updated_fmt = '%b %d, %Y'
181+
182+
# If true, SmartyPants will be used to convert quotes and dashes to
183+
# typographically correct entities.
184+
#html_use_smartypants = True
185+
186+
# Custom sidebar templates, maps document names to template names.
187+
#html_sidebars = {}
188+
189+
# Additional templates that should be rendered to pages, maps page names to
190+
# template names.
191+
#html_additional_pages = {}
192+
193+
# If false, no module index is generated.
194+
#html_domain_indices = True
195+
196+
# If false, no index is generated.
197+
#html_use_index = True
198+
199+
# If true, the index is split into individual pages for each letter.
200+
#html_split_index = False
201+
202+
# If true, links to the reST sources are added to the pages.
203+
#html_show_sourcelink = True
204+
205+
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
206+
#html_show_sphinx = True
207+
208+
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
209+
#html_show_copyright = True
210+
211+
# If true, an OpenSearch description file will be output, and all pages will
212+
# contain a <link> tag referring to it. The value of this option must be the
213+
# base URL from which the finished HTML is served.
214+
#html_use_opensearch = ''
215+
216+
# This is the file name suffix for HTML files (e.g. ".xhtml").
217+
#html_file_suffix = None
218+
219+
# Output file base name for HTML help builder.
220+
#htmlhelp_basename = 'azure-sdk-for-python-doc'
221+
222+
223+
# -- Options for LaTeX output ---------------------------------------------
224+
225+
#latex_elements = {
226+
# The paper size ('letterpaper' or 'a4paper').
227+
#'papersize': 'letterpaper',
228+
229+
# The font size ('10pt', '11pt' or '12pt').
230+
#'pointsize': '10pt',
231+
232+
# Additional stuff for the LaTeX preamble.
233+
#'preamble': '',
234+
#}
235+
236+
# Grouping the document tree into LaTeX files. List of tuples
237+
# (source start file, target name, title,
238+
# author, documentclass [howto, manual, or own class]).
239+
# latex_documents = [
240+
# ('index', 'azure-sdk-for-python.tex', u'Azure SDK for Python Documentation',
241+
# u'Microsoft', 'manual'),
242+
# ]
243+
244+
# The name of an image file (relative to this directory) to place at the top of
245+
# the title page.
246+
#latex_logo = None
247+
248+
# For "manual" documents, if this is true, then toplevel headings are parts,
249+
# not chapters.
250+
#latex_use_parts = False
251+
252+
# If true, show page references after internal links.
253+
#latex_show_pagerefs = False
254+
255+
# If true, show URL addresses after external links.
256+
#latex_show_urls = False
257+
258+
# Documents to append as an appendix to all manuals.
259+
#latex_appendices = []
260+
261+
# If false, no module index is generated.
262+
#latex_domain_indices = True
263+
264+

eng/pipelines/templates/jobs/archetype-sdk-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
vmImage: 'ubuntu-16.04'
1414

1515
steps:
16-
- template: ../steps/build-artifacts.yml
16+
- template: ../steps/build-package-artifacts.yml
1717
parameters:
1818
ServiceDirectory: ${{ parameters.ServiceDirectory }}
1919
BuildTargetingString: ${{ parameters.BuildTargetingString }}

eng/pipelines/templates/steps/build-artifacts.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ steps:
3030
versionSpec: $(PythonVersion)
3131

3232
- script: |
33-
pip install wheel setuptools pathlib twine readme-renderer[md] packaging
33+
pip install wheel setuptools pathlib twine readme-renderer[md] packaging tox tox-monorepo
3434
displayName: 'Prep Environment'
3535
3636
- task: PythonScript@0
@@ -43,6 +43,15 @@ steps:
4343
twine check $(Build.ArtifactStagingDirectory)/*
4444
displayName: 'Verify Readme'
4545
46+
- task: PythonScript@0
47+
displayName: 'Generate Docs'
48+
inputs:
49+
scriptPath: 'scripts/devops_tasks/setup_execute_tests.py'
50+
arguments: >-
51+
"${{ parameters.BuildTargetingString }}"
52+
--service="${{ parameters.ServiceDirectory }}"
53+
--toxenv=sphinx
54+
4655
- ${{ parameters.BeforePublishSteps }}
4756

4857
- task: PublishPipelineArtifact@0
@@ -54,4 +63,5 @@ steps:
5463
condition: succeededOrFailed()
5564
displayName: 'Publish Artifacts'
5665
inputs:
57-
artifactName: packages
66+
artifactName: 'docs'
67+
pathtoPublish: '$(Build.SourcesDirectory)/_docs'

0 commit comments

Comments
 (0)