Skip to content

Commit 38dae1d

Browse files
Merge pull request #4376 from YosysHQ/krys/docs_cmd_ref
Docs: Use formatted cmd ref in pdf
2 parents a54f632 + d1c6699 commit 38dae1d

File tree

6 files changed

+59
-21
lines changed

6 files changed

+59
-21
lines changed

.github/workflows/test-build.yml

+37
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,40 @@ jobs:
189189
shell: bash
190190
run: |
191191
make -C docs test -j${{ env.procs }}
192+
193+
test-docs-build:
194+
name: Try build docs
195+
runs-on: [self-hosted, linux, x64, fast]
196+
needs: [pre_docs_job]
197+
if: needs.pre_docs_job.outputs.should_skip != 'true'
198+
strategy:
199+
matrix:
200+
docs-target: [html, latexpdf]
201+
fail-fast: false
202+
steps:
203+
- name: Checkout Yosys
204+
uses: actions/checkout@v4
205+
with:
206+
submodules: true
207+
208+
- name: Runtime environment
209+
run: |
210+
echo "procs=$(nproc)" >> $GITHUB_ENV
211+
212+
- name: Build Yosys
213+
run: |
214+
make config-clang
215+
echo "ENABLE_CCACHE := 1" >> Makefile.conf
216+
make -j${{ env.procs }}
217+
218+
- name: Build docs
219+
shell: bash
220+
run: |
221+
make docs DOC_TARGET=${{ matrix.docs-target }} -j${{ env.procs }}
222+
223+
- name: Store docs build artifact
224+
uses: actions/upload-artifact@v4
225+
with:
226+
name: docs-build-${{ matrix.docs-target }}
227+
path: docs/build/
228+
retention-days: 7

Makefile

+4-7
Original file line numberDiff line numberDiff line change
@@ -996,12 +996,9 @@ docs/source/cell/word_add.rst: $(TARGETS) $(EXTRA_TARGETS)
996996
docs/source/generated/cells.json: docs/source/generated $(TARGETS) $(EXTRA_TARGETS)
997997
$(Q) ./$(PROGRAM_PREFIX)yosys -p 'help -dump-cells-json $@'
998998

999-
PHONY: docs/gen_examples docs/gen_images docs/guidelines docs/usage docs/reqs
1000-
docs/gen_examples: $(TARGETS)
1001-
$(Q) $(MAKE) -C docs examples
1002-
1003-
docs/gen_images: $(TARGETS)
1004-
$(Q) $(MAKE) -C docs images
999+
PHONY: docs/gen docs/guidelines docs/usage docs/reqs
1000+
docs/gen: $(TARGETS)
1001+
$(Q) $(MAKE) -C docs gen
10051002

10061003
DOCS_GUIDELINE_FILES := GettingStarted CodingStyle
10071004
DOCS_GUIDELINE_SOURCE := $(addprefix guidelines/,$(DOCS_GUIDELINE_FILES))
@@ -1037,7 +1034,7 @@ docs/reqs:
10371034
$(Q) $(MAKE) -C docs reqs
10381035

10391036
.PHONY: docs/prep
1040-
docs/prep: docs/source/cmd/abc.rst docs/source/generated/cells.json docs/gen_examples docs/gen_images docs/guidelines docs/usage
1037+
docs/prep: docs/source/cmd/abc.rst docs/source/generated/cells.json docs/gen docs/guidelines docs/usage
10411038

10421039
DOC_TARGET ?= html
10431040
docs: docs/prep

docs/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ images:
252252
$(MAKE) -C source/_images
253253
$(MAKE) -C source/_images convert
254254

255+
.PHONY: gen
256+
gen:
257+
$(MAKE) examples
258+
$(MAKE) images
259+
255260
.PHONY: reqs
256261
reqs:
257262
$(PYTHON) -m pip install -r source/requirements.txt

docs/source/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ available, go to :ref:`commandindex`.
2323
- Search bar with live drop down suggestions for matching on title /
2424
autocompleting commands
2525
- Scroll the left sidebar to the current location on page load
26-
- Also the formatting/linking in pdf is broken
26+
- Also the formatting in pdf uses link formatting instead of code formatting
2727

2828
.. todolist::
2929

docs/source/using_yosys/synthesis/synth.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The following commands are executed by the `prep` command:
4242

4343
.. literalinclude:: /cmd/prep.rst
4444
:start-at: begin:
45-
:end-before: .. raw:: latex
45+
:end-before: .. only:: latex
4646
:dedent:
4747

4848
:doc:`/getting_started/example_synth` covers most of these commands and what

kernel/register.cc

+11-12
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,11 @@ struct HelpPass : public Pass {
812812
fprintf(f, "%s", title_line.c_str());
813813
fprintf(f, "%s - %s\n", cmd.c_str(), title.c_str());
814814
fprintf(f, "%s\n", title_line.c_str());
815-
fprintf(f, ".. raw:: latex\n\n \\begin{comment}\n\n");
816815

817816
// render html
818817
fprintf(f, ".. cmd:def:: %s\n", cmd.c_str());
819-
fprintf(f, " :title: %s\n\n", title.c_str());
818+
fprintf(f, " :title: %s\n\n", title.c_str());
819+
fprintf(f, " .. only:: html\n\n");
820820
std::stringstream ss;
821821
std::string textcp = text;
822822
ss << text;
@@ -852,46 +852,45 @@ struct HelpPass : public Pass {
852852
if (IsUsage) {
853853
if (stripped_line.compare(0, 4, "See ") == 0) {
854854
// description refers to another function
855-
fprintf(f, "\n %s\n", stripped_line.c_str());
855+
fprintf(f, "\n %s\n", stripped_line.c_str());
856856
} else {
857857
// usage should be the first line of help output
858-
fprintf(f, "\n .. code:: yoscrypt\n\n %s\n\n ", stripped_line.c_str());
858+
fprintf(f, "\n .. code:: yoscrypt\n\n %s\n\n ", stripped_line.c_str());
859859
WasDefinition = true;
860860
}
861861
IsUsage = false;
862862
} else if (IsIndent && NewUsage && (blank_count >= 2 || WasDefinition)) {
863863
// another usage block
864-
fprintf(f, "\n .. code:: yoscrypt\n\n %s\n\n ", stripped_line.c_str());
864+
fprintf(f, "\n .. code:: yoscrypt\n\n %s\n\n ", stripped_line.c_str());
865865
WasDefinition = true;
866866
def_strip_count = 0;
867867
} else if (IsIndent && IsDefinition && (blank_count || WasDefinition)) {
868868
// format definition term
869-
fprintf(f, "\n\n .. code:: yoscrypt\n\n %s\n\n ", stripped_line.c_str());
869+
fprintf(f, "\n\n .. code:: yoscrypt\n\n %s\n\n ", stripped_line.c_str());
870870
WasDefinition = true;
871871
def_strip_count = first_pos;
872872
} else {
873873
if (IsDedent) {
874-
fprintf(f, "\n\n ::\n");
874+
fprintf(f, "\n\n ::\n");
875875
def_strip_count = first_pos;
876876
} else if (WasDefinition) {
877-
fprintf(f, " ::\n");
877+
fprintf(f, "::\n");
878878
WasDefinition = false;
879879
}
880-
fprintf(f, "\n %s", line.substr(def_strip_count, std::string::npos).c_str());
880+
fprintf(f, "\n %s", line.substr(def_strip_count, std::string::npos).c_str());
881881
}
882882

883883
blank_count = 0;
884884
}
885885
fputc('\n', f);
886886

887887
// render latex
888-
fprintf(f, ".. raw:: latex\n\n \\end{comment}\n\n");
889888
fprintf(f, ".. only:: latex\n\n");
890-
fprintf(f, " ::\n\n");
889+
fprintf(f, " ::\n\n");
891890
std::stringstream ss2;
892891
ss2 << textcp;
893892
for (std::string line; std::getline(ss2, line, '\n');) {
894-
fprintf(f, " %s\n", line.c_str());
893+
fprintf(f, " %s\n", line.c_str());
895894
}
896895
fclose(f);
897896
}

0 commit comments

Comments
 (0)