Metadata-Version: 2.4
Name: sphinx-hackerrank
Version: 2026.11.6.1
Summary: Build portable HackerRank Interviewer Guidelines from Sphinx documentation.
Author-email: Adam Dangoor <adamdangoor@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Rippling
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Issues, https://github.com/adamtheturtle/sphinx-hackerrank/issues
Project-URL: Source, https://github.com/adamtheturtle/sphinx-hackerrank
Keywords: documentation,rst,sphinx
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: Sphinx :: Extension
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Python: >=3.12
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: beautifulsoup4>=4.15.0
Requires-Dist: docutils>=0.21.2
Requires-Dist: sphinx<10,>=9.1.1
Dynamic: license-file

|Build Status| |PyPI|

sphinx-hackerrank
=================

Export Sphinx documentation as self-contained HTML for HackerRank Interviewer Guidelines, with styles and images.
Build and preview locally without HackerRank credentials.

Quick start
-----------

In an existing Sphinx project:

.. code-block:: console

   pip install sphinx-hackerrank

Add ``"sphinx_hackerrank"`` to ``extensions`` in ``docs/conf.py``.
Create ``docs/review.rst`` and add ``review`` to your existing toctree:

.. code-block:: rst

   Widget review
   =============

   .. hackerrank-export:: interviewer-guidelines/review.html
      :name: Widget review

      Interviewer instructions go here.

      .. code-block:: text

         example input

Build:

.. code-block:: console

   sphinx-build -W -b hackerrank docs build/hackerrank

Open ``build/hackerrank/interviewer-guidelines/index.html`` to preview the exports.
Upload ``build/hackerrank/interviewer-guidelines/review.html`` using your own publishing tool.

Code blocks are exported as ``<pre><code>`` with their original text and whitespace.
HackerRank's project IDE adds native copy controls to these blocks in its Guidelines tab.
Hover over a code block to reveal its Copy button.
Check copying inside a project interview.
The standalone preview displays the exported HTML without the IDE's controls.

Choosing content
----------------

Wrap content in ``hackerrank-export`` and give it an HTML output path relative to the build directory.
The required ``:name:`` option supplies the preview index label.
Each boundary is a Sphinx node carrying its destination and name.
No CSS selector or export list is needed.
Multiple boundaries in the same document export independently.
Destinations must be unique and must not overwrite documentation pages or the preview index.
The builder also produces ordinary themed documentation pages with the same content and bundled styles.

Python extensions can construct the same boundary directly:

.. code-block:: python

   """Declare an export around prepared Docutils content."""

   from docutils import nodes

   from sphinx_hackerrank import GuidelineExportNode

   content = GuidelineExportNode(
       output_path="interviewer-guidelines/review.html",
       name="Widget review",
   )
   content += nodes.paragraph("", "Interviewer instructions go here.")
   assert content.astext() == "Interviewer instructions go here."

The HTML translator captures the boundary while rendering the full document, preserving Sphinx's resolved references and image paths.
Export metadata is retained across incremental and parallel builds.
Other builders receive ordinary containers, preserving their native rendering without additional node handlers.

For collapsible sections, enable `sphinx-toolbox.collapse <https://sphinx-toolbox.readthedocs.io/en/stable/extensions/collapse.html>`_.
To reuse guide sections, enable `sphinx-section-include <https://github.com/adamtheturtle/sphinx-section-include>`_.
See the `sample project <https://github.com/adamtheturtle/sphinx-hackerrank/tree/main/sample>`_ for both.

Migrating from selector exports
-------------------------------

Replace each ``GuidelineExport`` configuration entry with a ``hackerrank-export`` directive or ``GuidelineExportNode`` around the content being exported.
Move ``output_path`` and ``name`` to that boundary, then remove ``hackerrank_exports`` and the old ``GuidelineExport`` import.
A separate ``docname`` and ``selector`` are no longer needed.
CSS classes remain presentation details.

Source links
------------

Links to other pages point to the local build by default.
To link to hosted documentation, set ``hackerrank_source_url = "https://example.org/guides/"`` in ``conf.py``.
For source files, set ``hackerrank_source_suffix = ".rst"`` too.
Set ``hackerrank_source_anchors = False`` if the destination does not support anchors.

Contributing
------------

See `CONTRIBUTING.rst <https://github.com/adamtheturtle/sphinx-hackerrank/blob/main/CONTRIBUTING.rst>`_ for checks and releases.
MIT licensed.

.. |Build Status| image:: https://github.com/adamtheturtle/sphinx-hackerrank/actions/workflows/ci.yml/badge.svg?branch=main
   :target: https://github.com/adamtheturtle/sphinx-hackerrank/actions
.. |PyPI| image:: https://badge.fury.io/py/sphinx-hackerrank.svg
   :target: https://badge.fury.io/py/sphinx-hackerrank
