1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2025-07-02 14:04:15 +00:00

Document the Python bindings using Sphinx

Additionally, setup the documentation for
deployment to Read The Docs.
This commit is contained in:
Pavol Žáčik 2024-07-23 18:04:47 +02:00 committed by The Tumultuous Unicorn Of Darkness
parent 40e2d5fcb6
commit ec938b5d42
15 changed files with 226 additions and 1 deletions

View file

@ -0,0 +1,6 @@
Clock and frequency computation
===============================
.. automodule:: libcpuid.clock
:members:
:undoc-members:

View file

@ -0,0 +1,6 @@
Enumeration classes
===================
.. automodule:: libcpuid.enums
:members:
:undoc-members:

View file

@ -0,0 +1,5 @@
Library exceptions
==================
.. automodule:: libcpuid.errors
:members:

22
python/docs/api/info.rst Normal file
View file

@ -0,0 +1,22 @@
Basic CPU information
=====================
.. autoclass:: libcpuid.info.CPUInfo
:members:
:exclude-members: from_c
.. autoclass:: libcpuid.info.X86Info
:members:
.. autoclass:: libcpuid.info.ARMInfo
:members:
.. autoclass:: libcpuid.sgx.SGX
:members:
.. autoclass:: libcpuid.sgx.EPC
:members:
.. autoclass:: libcpuid.info.SystemInfo
:members:
:exclude-members: from_c

View file

@ -0,0 +1,5 @@
Top-level library functionality
===============================
.. automodule:: libcpuid
:members:

6
python/docs/api/msr.rst Normal file
View file

@ -0,0 +1,6 @@
Model-specific registers
========================
.. automodule:: libcpuid.msr
:members:
:undoc-members:

10
python/docs/api/raw.rst Normal file
View file

@ -0,0 +1,10 @@
Raw CPU data
============
.. autoclass:: libcpuid.raw.CPURawData
:members:
:exclude-members: c_cpu_raw_data
.. autoclass:: libcpuid.raw.CPURawDataArray
:members:
:exclude-members: c_cpu_raw_data_array

35
python/docs/conf.py Normal file
View file

@ -0,0 +1,35 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
import os
import sys
sys.path.insert(0, os.path.abspath("../src"))
project = "libcpuid"
copyright = "2024, Pavol Žáčik"
author = "Pavol Žáčik"
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx_rtd_theme",
]
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
language = "en"
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = "sphinx_rtd_theme"
autodoc_member_order = "bysource"

51
python/docs/index.rst Normal file
View file

@ -0,0 +1,51 @@
Welcome to libcpuid's documentation!
====================================
**libcpuid** provides a Python interface
to the libcpuid C library.
.. code-block:: python
import sys
import libcpuid
from libcpuid.errors import LibcpuidError
from libcpuid.info import CPUInfo
from libcpuid.enums import CPUFeature, CPUVendor
# print the version of the libcpuid library
print(libcpuid.version())
# print the number of CPU cores
print(libcpuid.get_total_cpus())
# check if the cpuid instruction is available
if not libcpuid.cpuid_present():
print("CPUInfo instruction is not available")
sys.exit(1)
try:
# identify the current CPU and print some
# information about it
cpu_info = CPUInfo.from_current_cpu()
print(cpu_info.vendor)
print(cpu_info.architecture)
print(CPUFeature.FPU in cpu_info.features)
# print the list of all Intel CPU code names
print(libcpuid.get_cpu_list(CPUVendor.INTEL))
except LibcpuidError as err:
print(err.message)
sys.exit(1)
.. toctree::
:maxdepth: 2
Home <self>
api/libcpuid
api/info
api/msr
api/enums
api/raw
api/clock
api/errors

View file

@ -0,0 +1 @@
sphinx-rtd-theme