Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ Run the following command inside the `docs` folder to build the HTML:

```bash
# build page in docs folder
python setup_docs.py # downloads files from bigbio/quantms/docs folder,
# called in conf.py if built on Read The Docs.
sphinx-build -n -W --keep-going -b html ./ ./_build/
```
4 changes: 4 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# build artifacts
_build
# downloaded from bigbio/quantms
quantms_output.md
22 changes: 20 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
# 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 os

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

Expand All @@ -22,7 +23,7 @@
author = 'daichengxin, jpfeuffer, timosachenberg, ypriverol'

# The full version, including alpha/beta/rc tags
release = '1.4.0'
release = '1.5.0'


# -- General configuration ---------------------------------------------------
Expand All @@ -31,6 +32,9 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx_new_tab_link",
"myst_nb",
"sphinx_copybutton",
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -55,3 +59,17 @@
# 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']

if os.environ.get("READTHEDOCS") == "True":
# If we are building on ReadTheDocs, we need to download the output file
# from the GitHub repository.
def download_files(_):
from setup_docs import download_output
Copy link

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Importing setup_docs by filename may fail if the module search path changes. Consider adding docs to sys.path or using an explicit path insertion in conf.py to ensure the import always works.

Copilot uses AI. Check for mistakes.


# Download the output file
download_output()

def setup(app):
# on extensions, see:
# https://www.sphinx-doc.org/en/master/usage/extensions/index.html
app.connect("builder-inited", download_files)
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Contents
usage
introduction
formats
quantms_output
preprocessing
identification
dda
Expand Down
55 changes: 55 additions & 0 deletions docs/setup_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import requests

OUTPUT_URL = (
"https://github.com/bigbio/quantms/raw/refs/heads/README_links/docs/output.md"
)


def download_file(url, save_path, timeout=20):
"""
Download a file from a URL and save it to the specified path.

Args:
url (str): URL of the file to download
save_path (str): Path where the downloaded file will be saved
timeout (int): Timeout for the download request in seconds

Returns:
bool: True if download was successful, False otherwise
"""

# Send GET request
response = requests.get(url, stream=True, timeout=timeout)
response.raise_for_status() # Raise exception for HTTP errors

# Write content to file
with open(save_path, "wb") as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)

print(f"Successfully downloaded: {url} to {save_path}")
return True


def download_output(output_path="quantms_output.md"):
"""
Download the output file from the specified URL and save it locally to use
for Sphinx documentation purposes.
"""
# new folders would need to be created if necessary

assert download_file(OUTPUT_URL, output_path) # prints success message

with open(output_path, "r") as f:
content = f.readlines()

assert len(content) > 0, "Downloaded file is empty"

content[0] = "# quantms outputs\n"

with open(output_path, "w") as f:
f.writelines(content)


if __name__ == "__main__":
download_output()
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
sphinx
furo
myst-nb
sphinx-new-tab-link
sphinx-copybutton