From ec4f89e2f1e8306da9c415f5e3a4f6faa8cea7d6 Mon Sep 17 00:00:00 2001 From: RibhuDP Date: Wed, 3 Apr 2024 15:25:58 +0530 Subject: [PATCH] docs: Generate ref API index.rst from scratch Signed-off-by: RibhuDP --- docs/source/reference_api/gen_sysobj_doc.m | 26 +++++++++++++++++-- docs/source/reference_api/index_template.tmpl | 6 +++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 docs/source/reference_api/index_template.tmpl diff --git a/docs/source/reference_api/gen_sysobj_doc.m b/docs/source/reference_api/gen_sysobj_doc.m index c012bb6..c554aa1 100644 --- a/docs/source/reference_api/gen_sysobj_doc.m +++ b/docs/source/reference_api/gen_sysobj_doc.m @@ -1,6 +1,5 @@ [filepath,name,ext] = fileparts(mfilename('fullpath')); cd(filepath); -%cd('..'); mfiledir = fullfile('adi'); @@ -110,13 +109,36 @@ rstFiles = [rstFiles, convertCharsToStrings([' ' part '_' trx_file '.rst'])]; end +end + +%% Overwrite any existing index.rst file +if isfile('index_template.tmpl') + template = []; + fileID = fopen('index_template.tmpl','r'); + current_line = convertCharsToStrings(fgetl(fileID)); + while isstring(current_line) + template = [template, current_line]; + current_line = convertCharsToStrings(fgetl(fileID)); + end + fclose(fileID); + + disp(length(template)) + fileID = fopen('index.rst','wt'); + for i = 1:length(template) + fprintf(fileID, template(i)); + fprintf(fileID, '\n'); + end + + fclose(fileID); + end %% Add toctree to the reference api index.rst file using the rstFiles fileID = fopen('index.rst','a+'); +fprintf(fileID, '\n'); for i = 1:length(rstFiles) - fprintf(fileID, '\n'); fprintf(fileID, "%s", rstFiles(i)); + fprintf(fileID, '\n'); end fclose(fileID); diff --git a/docs/source/reference_api/index_template.tmpl b/docs/source/reference_api/index_template.tmpl new file mode 100644 index 0000000..7958b1e --- /dev/null +++ b/docs/source/reference_api/index_template.tmpl @@ -0,0 +1,6 @@ +Reference APIs +-------------- + +.. toctree:: + :maxdepth: 1 + :caption: Driver Classes: