Skip to content

Commit

Permalink
Produce Dash docset for offline reference.
Browse files Browse the repository at this point in the history
* Added post-process script which generates Dash docset
  from Sphinx html documentation.
* Updated anchors for attributes and methods because
  they are used to generate index.
  • Loading branch information
ytimenkov committed Apr 25, 2018
1 parent 421b19e commit f748049
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 31 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,7 @@ pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

.PHONY: dash
dash: html
python make_docset.py
Binary file added _static/conan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ['_build', 'env']

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand Down
4 changes: 2 additions & 2 deletions creating_packages/define_abi_compatibility.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Define package ABI compatibility
Each package recipe can generate *N* binary packages from it, depending on three things:
``settings``, ``options`` and ``requires``.

When any of the :ref:`settings_property` of a package recipe changes, it will reference a
When any of the :ref:`attribute_settings` of a package recipe changes, it will reference a
different binary:

.. code-block:: python
Expand Down Expand Up @@ -50,7 +50,7 @@ the computed package ID will be the same, such binary will be retrieved, and the
to reuse the binary without building it from sources.

The use case for ``options`` is very similar, the main difference is that options can be more easily
defined at the package level and they can be defaulted. Check the :ref:`conanfile_options`
defined at the package level and they can be defaulted. Check the :ref:`attribute_options`
reference.

Note the simple scenario of a **header-only** library. Such package does not need to be built, and
Expand Down
2 changes: 1 addition & 1 deletion integrations/git.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Package creators

If you are creating a **conan** package:

- You can use the :ref:`url field <package_url>` to indicate the origin of your package recipe. If you are using an
- You can use the :ref:`url field <attribute_url>` to indicate the origin of your package recipe. If you are using an
external package recipe, this url should point to the package recipe repository **not** to the
external source origin.
If a **github** repository is detected, the conan website will link your github issues page from your conan's package page.
Expand Down
88 changes: 88 additions & 0 deletions make_docset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
BUILD_DIR = "_build"

import doc2dash.__main__
import doc2dash.parsers

from doc2dash.parsers.intersphinx import (InterSphinxParser, inv_entry_to_path,
ParserEntry)


class InterSphinxWithUserGuide(InterSphinxParser):
def convert_type(self, inv_type):
#print("Processing type {}".format(inv_type))
if inv_type == "std:doc":
return "Guide"
elif inv_type == "std:cmdoption":
return "Option"
elif inv_type == "std:label":
return "Label"
return super(InterSphinxWithUserGuide, self).convert_type(inv_type)

def create_entry(self, dash_type, key, inv_entry):
#print(dash_type, key, inv_entry) # for debugging
entry_name = inv_entry[3]
if dash_type == "Guide":
if inv_entry[2].startswith("reference/config_files/"):
dash_type = "File"
elif inv_entry[2].startswith("reference/generators/"):
dash_type = "Plugin"
elif inv_entry[2].startswith("reference/commands/"):
dash_type = "Command"
entry_name = inv_entry[3].replace("conan ", "")
elif inv_entry[2].startswith("reference/build_helpers/"):
dash_type = "Class"
path_str = inv_entry_to_path(inv_entry)
return ParserEntry(name=entry_name, type=dash_type, path=path_str)
elif dash_type == "Label":
if inv_entry[2].startswith("reference/conanfile/methods"):
if key.startswith("method_package_info_"):
return None
dash_type = "Method"
entry_name = key.replace("method_", "")
elif inv_entry[2].startswith("reference/conanfile/attributes"):
dash_type = "Attribute"
entry_name = key.replace("attribute_", "")
elif inv_entry[2].startswith("reference/conanfile/other"):
if key.startswith("attribute"):
dash_type = "Attribute"
entry_name = key.replace("attribute_", "")
elif key.startswith("method"):
dash_type = "Method"
entry_name = key.replace("method_", "")
else:
return None
elif inv_entry[2].startswith("reference/reference/env_vars"):
dash_type = "Environment"
else:
return None
path_str = inv_entry_to_path(inv_entry)
return ParserEntry(name=entry_name, type=dash_type, path=path_str)
return super(InterSphinxWithUserGuide, self).create_entry(
dash_type, key, inv_entry)


doc2dash.parsers.DOCTYPES = [InterSphinxWithUserGuide]

try:
# pylint: disable=E1120
doc2dash.__main__.main([
"-f", "-nConan", "-i_static/conan.png", "-d{}/dash".format(BUILD_DIR),
"-Iindex.html", "{}/html".format(BUILD_DIR)
])
except SystemExit as e:
if e.code != 0:
raise

CSS_CUSTOMIZATION = """
div[role=navigation] {display:none}
.wy-nav-content-wrap {margin-left: 0}
footer {display:none}
nav {display:none !important}
"""

print("Patching CSS...")

with open(
"{}/dash/Conan.docset/Contents/Resources/Documents/_static/css/theme.css".
format(BUILD_DIR), "a") as f:
f.write(CSS_CUSTOMIZATION)
2 changes: 1 addition & 1 deletion mastering/conditional.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ Here is an example of what we could do in our **configure method**:
self.requires("OpenSSL/1.0.2d@lasote/stable")
.. seealso:: Check the section :ref:`Reference/conanfile.py/configure(), config_options() <method_configure_config_options>` to find out more.
.. seealso:: Check the section :ref:`Reference/conanfile.py/configure(), config_options() <method_configure>` to find out more.
2 changes: 1 addition & 1 deletion reference/build_helpers/cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Parameters:
The ``CMake`` object will store ``build_folder`` internally for subsequent calls to ``build()``.
- **cache_build_folder** (Optional, Defaulted to ``None``): Use the given subfolder as build folder when building the package in the local cache.
This argument doesn't have effect when the package is being built in user folder with :command:`conan build` but overrides **build_folder** when working in the local cache.
See :ref:`self.in_local_cache<in_local_cache>`.
See :ref:`self.in_local_cache<attribute_in_local_cache>`.

build()
+++++++
Expand Down
2 changes: 1 addition & 1 deletion reference/build_helpers/meson.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Parameters:
- **pkg_config_paths** (Optional, Defaulted to ``None``): A list containing paths to locate the pkg-config files (\*.pc). If ``None``, it will be set to ``conanfile.build_folder``.
- **cache_build_folder** (Optional, Defaulted to ``None``): Subfolder to be used as build folder when building the package in the local cache.
This argument doesn't have effect when the package is being built in user folder with :command:`conan build` but overrides **build_folder** when working in the local cache.
See :ref:`self.in_local_cache<in_local_cache>`.
See :ref:`self.in_local_cache<attribute_in_local_cache>`.

build()
+++++++
Expand Down
2 changes: 1 addition & 1 deletion reference/commands/output/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The output JSON contains a two first level keys:
- **time**: ``ISO 8601`` string with the time the recipe was downloaded/retrieved.
- **error**: ``true``/``false``.
- **id**: Reference. e.j: "OpenSSL/1.0.2n@conan/stable"
- **dependency**: ``true``/``false``. Is the package being installed/created or a dependency. Same as :ref:`develop conanfile attribute<develop_attribute>`.
- **dependency**: ``true``/``false``. Is the package being installed/created or a dependency. Same as :ref:`develop conanfile attribute<attribute_develop>`.

- **packages**: List of elements, representing the binary packages downloaded for the recipe.
Normally it will be only 1 element in this list, only in special cases with build requires, private
Expand Down
Loading

0 comments on commit f748049

Please sign in to comment.