Add clib example to sphinx-gallery

This commit is contained in:
Ray Speth 2023-09-20 14:49:35 -04:00 committed by Ray Speth
parent 732e7e89fa
commit 6eb4f08907
5 changed files with 24 additions and 3 deletions

View File

@ -146,6 +146,13 @@ if localenv['sphinx_docs']:
localenv.Command(f"#build/doc/samples/fortran/{fort_file.name}", localenv.Command(f"#build/doc/samples/fortran/{fort_file.name}",
fort_file, Copy("$TARGET", "$SOURCE"))) fort_file, Copy("$TARGET", "$SOURCE")))
# Gather clib sample files
clib_files = Glob("#samples/clib/*.c") + [File("#samples/clib/README.rst")]
for clib_file in clib_files:
env.Depends(sphinxdocs,
localenv.Command(f"#build/doc/samples/clib/{clib_file.name}",
clib_file, Copy("$TARGET", "$SOURCE")))
# Create a list of MATLAB classes to document. This uses the NamedTuple # Create a list of MATLAB classes to document. This uses the NamedTuple
# structure defined at the top of the file. The @Data and @Utilities # structure defined at the top of the file. The @Data and @Utilities
# classes are fake classes for the purposes of documentation only. Each # classes are fake classes for the purposes of documentation only. Each

View File

@ -49,17 +49,19 @@ extensions = [
sphinx_gallery_conf = { sphinx_gallery_conf = {
'filename_pattern': '\.py', 'filename_pattern': '\.py',
'example_extensions': {'.py', '.cpp', '.h', '.f', '.f90'}, 'example_extensions': {'.py', '.cpp', '.h', '.c', '.f', '.f90'},
"filetype_parsers": {'.h': 'C++'}, "filetype_parsers": {'.h': 'C++'},
'image_srcset': ["2x"], 'image_srcset': ["2x"],
'examples_dirs': [ 'examples_dirs': [
'../samples/python/', '../samples/python/',
'../samples/cxx/', '../samples/cxx/',
'../samples/clib/',
'../samples/fortran/', '../samples/fortran/',
], ],
'gallery_dirs': [ 'gallery_dirs': [
'examples/python', 'examples/python',
'examples/cxx', 'examples/cxx',
'examples/clib',
'examples/fortran', 'examples/fortran',
], ],
'reference_url': { 'reference_url': {
@ -122,6 +124,7 @@ tags_page_header = "Examples with this tag:"
tags_badge_colors = { tags_badge_colors = {
"Python": "secondary", "Python": "secondary",
"C++": "secondary", "C++": "secondary",
"C": "secondary",
"Fortran 77": "secondary", "Fortran 77": "secondary",
"Fortran 90": "secondary", "Fortran 90": "secondary",
} }

View File

@ -17,6 +17,7 @@ format.
examples/python/index examples/python/index
examples/cxx/index examples/cxx/index
examples/clib/index
examples/fortran/index examples/fortran/index
_tags/tagsindex _tags/tagsindex

6
samples/clib/README.rst Normal file
View File

@ -0,0 +1,6 @@
C Examples
==========
These examples demonstrate the usage of Cantera's C interface library, ``clib``,
which can also be used to call Cantera from other languages that are able to
call C functions.

View File

@ -1,11 +1,13 @@
/** /*
* CLib Demo * CLib Demo
* =========
* *
* This program illustrates using Cantera's C-library interface to compute * This program illustrates using Cantera's C-library interface to compute
* thermodynamic, kinetic, and transport properties of a gas mixture. In addition, * thermodynamic, kinetic, and transport properties of a gas mixture. In addition,
* a simple reactor network simulation is illustrated. * a simple reactor network simulation is illustrated.
* *
* Keywords: tutorial, equilibrium, thermodynamics, kinetics, transport, reactor network * .. tags:: C, tutorial, equilibrium, thermodynamics, kinetics, transport,
* reactor network
*/ */
// This file is part of Cantera. See License.txt in the top-level directory or // This file is part of Cantera. See License.txt in the top-level directory or
@ -16,6 +18,7 @@
#include <stdio.h> #include <stdio.h>
// sphinx_gallery_start_ignore
// The following header files are not used by this example, but are nevertheless added // The following header files are not used by this example, but are nevertheless added
// here to ensure C-compatibility of Cantera's clib includes in continuous testing. // here to ensure C-compatibility of Cantera's clib includes in continuous testing.
#include "cantera/clib/ctfunc.h" #include "cantera/clib/ctfunc.h"
@ -23,6 +26,7 @@
#include "cantera/clib/ctonedim.h" #include "cantera/clib/ctonedim.h"
#include "cantera/clib/ctrpath.h" #include "cantera/clib/ctrpath.h"
#include "cantera/clib/ctsurf.h" #include "cantera/clib/ctsurf.h"
// sphinx_gallery_end_ignore
void exit_with_error() void exit_with_error()
{ {