एक छोटी किताब बनाएँ¶
वेबसाइट आपस में जुड़े पेजों का जाल है। पाठक उसे किसी भी क्रम में पढ़ते हैं। किताब को सोचा-समझा पढ़ने का क्रम चाहिए, साथ में क्रमांकित अध्याय, रनिंग हेडर और शुरुआती पन्ने (फ़्रंट मैटर)।
Guidedog में विषय-सूची निर्देश (toctree) दोनों फ़ॉर्मैट का काम करता है। एक ही toctree हमारे दस्तावेज़ों को वेब के लिए साइडबार ट्री में और PDF किताब के लिए अध्यायों के क्रम में सजाता है।
1. नया अध्याय जोड़ें¶
अपने notes प्रोजेक्ट में हम measurement.rst नाम का नया दस्तावेज़ बनाते हैं:
Measurement
===========
A scientific measurement consists of a numerical magnitude and an explicit unit.
Always report both. A bare number leaves the reader guessing.
.. _measurement-units:
Units of measurement
--------------------
Maintain a single, consistent unit system within every comparison.
When working with the International System of Units (SI):
* Length is expressed in meters (m).
* Mass is expressed in kilograms (kg).
* Time is expressed in seconds (s).
Prefixes scale units by powers of ten, simplifying very large or small values.
शीर्षक के ठीक ऊपर सेक्शन लेबल .. _measurement-units: पर ध्यान दें। लेबल क्रॉस-रेफ़रेंस का टार्गेट बनाता है। यह वेब और प्रिंट दोनों में एक जैसा काम करता है।
2. पढ़ने का क्रम रखें¶
हम notes/index.rst खोलते हैं और विषय-सूची घोषित करते हैं:
Field Notes
===========
These notes explain how to perform reliable physical measurements and document
them clearly.
.. toctree::
:maxdepth: 2
:numbered:
measurement
Next steps:
* Begin with :doc:`measurement`.
* Review the standard unit conventions in :ref:`measurement-units`.
toctree के विकल्पों का मतलब यह है:
:maxdepth: 2तय करता है कि विषय-सूची में उपशीर्षक कितने स्तर तक दिखें।:numbered:अध्यायों और उनके सेक्शन को नंबर देता है (जैसे "1. Measurement" और "1.1 Units of measurement")।measurementमें फ़ाइल का नाम है, बिना.rstके।
क्रॉस-रेफ़रेंस इस तरह काम करते हैं:
:doc:`measurement`पथ से अध्याय जोड़ता है।:ref:`measurement-units`लेबल वाले सेक्शन का लिंक बनाता है। PDF में सेक्शन का शीर्षक आता है। किताब का templatepage-refके ज़रिए पेज नंबर भी जोड़ सकता है। काम करता हुआ उदाहरण प्रोजेक्ट की थीम बनाना में देखें।
3. Graphviz चित्र जोड़ें¶
डायग्राम संबंधों को साफ़ दिखाता है। Guidedog में Graphviz इंजन जुड़ा हुआ है। यह वेक्टर डायग्राम वेब पेजों के लिए SVG के रूप में और प्रिंट के लिए PDF ड्रॉइंग के रूप में बनाता है। किसी बाहरी रेंडरर की ज़रूरत नहीं।
हम notes/measurement.rst में एक डायग्राम जोड़ते हैं:
Comparison workflow
-------------------
Before comparing two experimental values, convert both to a shared base unit:
.. graphviz::
:class: graphviz-adaptive
:caption: Converting values to a common base unit before comparison.
:alt: Raw experimental values are converted to a shared unit before comparison.
digraph comparison {
graph [rankdir=LR, bgcolor="transparent", pad="0.2"];
node [shape=box, style="rounded,filled", fillcolor="#edf5f2",
color="#216553", fontname="Helvetica", fontcolor="#16382f", fontsize=12];
edge [color="#216553"];
"Raw values" -> "Unit conversion" -> "Common unit" -> "Comparison";
}
:caption: विकल्प कैप्शन देता है। चित्रों को नंबर देने के लिए हम notes/conf.toml में numfig = true जोड़ते हैं। :alt: विकल्प स्क्रीन रीडर के लिए वैकल्पिक टेक्स्ट देता है।
4. किताब बनाएँ और जाँचें¶
हम प्रोजेक्ट दोबारा build करते हैं:
guidedog build html notes -W
guidedog build pdf notes -W
हम दोनों फ़ॉर्मैट में नतीजे जाँचते हैं:
- HTML वेबसाइट:
notes/_build/html/index.htmlखोलें। अब साइडबार में क्रमांकित अध्याय दिखते हैं। "1. Measurement" पर क्लिक करने से नया पेज खुलता है, जिसमें ब्रेडक्रम्ब और SVG डायग्राम है। - PDF:
notes/_build/pdf/field-notes-en.pdfखोलें। विषय-सूची अध्याय और पेज देती है। चित्र वेक्टर रहता है और संदर्भ सही लक्ष्य पर जाते हैं।
5. आगे क्या पढ़ें¶
अब हम जानते हैं कि एक ही सोर्स से दो आउटपुट कैसे बनते हैं। विषय (topics) वाला भाग इससे आगे ले जाता है:
- मार्कअप, सूचियाँ और टेबल दस्तावेज़ लिखना में हैं।
- फ़ॉर्मूले और समीकरण गणित और प्रमाण में हैं।
- Graphviz और Typst आरेख Graphviz और Typst से आरेख में हैं।
- कस्टम स्टाइल और किताब के फ़ॉन्ट पढ़ने के लिए टाइपोग्राफ़ी में हैं।