<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ docs - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ docs - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Wed, 13 May 2026 22:45:00 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/docs/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Merge Word Documents in Python – Three Effective Methods with Examples ]]>
                </title>
                <description>
                    <![CDATA[ In today's fast-paced work environment, automation is crucial for optimizing your repetitive tasks and enhancing your productivity. Deploying Python functions to automate the merging of multiple Word documents into a single, cohesive file can help yo... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/merge-word-documents-in-python/</link>
                <guid isPermaLink="false">66bb959b6a3faffa7d146ab7</guid>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ automation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ docs ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Vikram Aruchamy ]]>
                </dc:creator>
                <pubDate>Tue, 13 Aug 2024 17:19:23 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1723552225928/558a428b-d6a1-487c-a563-5aa6bee8e029.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In today's fast-paced work environment, automation is crucial for optimizing your repetitive tasks and enhancing your productivity.</p>
<p>Deploying Python functions to automate the merging of multiple Word documents into a single, cohesive file can help you streamline your document management processes. This approach not only saves time but also ensures consistent and accurate deliverables.</p>
<p>By integrating these automated processes into your workflows, such as during build triggers or scheduled tasks, you and your team can further enhance efficiency and reduce manual effort.</p>
<p>In this article, we’ll explore three effective methods for <a target="_blank" href="https://www.docstomarkdown.pro/combine-multiple-word-documents-into-one/">merging multiple Word documents into one</a>: <code>docxcompose</code>, <code>pypandoc</code>, and <code>python-docx</code>. Each method has its unique strengths and is suited for different use cases.</p>
<h2 id="heading-1-how-to-merge-documents-with-docxcompose">1. How to Merge Documents with <code>docxcompose</code></h2>
<p><a target="_blank" href="https://pypi.org/project/docxcompose/"><code>docxcompose</code></a> is a specialized Python library designed explicitly for <a target="_blank" href="https://workspace.google.com/marketplace/app/merge_docs_pro/61337277026">merging Word documents</a> while preserving their complex formatting and structural elements.</p>
<p>Unlike general-purpose libraries, <code>docxcompose</code> focuses on maintaining document integrity during the merge process. This makes it the right choice for tasks where preserving headers, footers, and custom styles is essential.</p>
<p><strong>Key Features</strong></p>
<ol>
<li><p><strong>Preserves Complex Formatting</strong> – Ensures that headers, footers, and styles from each document are retained in the final merged output.</p>
</li>
<li><p><strong>Sequential Merging</strong> – Allows for appending multiple documents in a specified order, making it suitable for structured document assembly.</p>
</li>
<li><p><strong>Easy Integration</strong> – Designed to work seamlessly with the <code>python-docx</code> library, making it easy to incorporate into existing workflows.</p>
</li>
<li><p><strong>Processing Time</strong> – <code>docxcompose</code> is optimized for merging large documents while preserving complex formatting and styles. It processes documents sequentially, which can lead to slower performance for very large documents.</p>
</li>
<li><p><strong>Memory Usage</strong> – <code>docxcompose</code> requires moderate memory usage, as it needs to store the merged document in memory before saving it to disk.</p>
</li>
</ol>
<h3 id="heading-docxcompose-use-case"><code>docxcompose</code> Use Case</h3>
<p>Use <code>docxcompose</code> when:</p>
<ol>
<li><p>You need to combine DOCX files while preserving detailed formatting and layout elements.</p>
</li>
<li><p>You are dealing with documents that include various styles, headers, footers, or other advanced formatting features.</p>
</li>
<li><p>Your primary goal is to merge documents without losing any of their original formatting or structure.</p>
</li>
</ol>
<h3 id="heading-how-to-install-docxcompose">How to Install <code>docxcompose</code></h3>
<p>To use <code>docxcompose</code>, install the library with the following command:</p>
<pre><code class="lang-python">pip install docxcompose
</code></pre>
<h3 id="heading-example-code">Example Code</h3>
<p>Here’s a Python script that uses <code>docxcompose</code> to merge multiple DOCX files:</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> docxcompose.composer <span class="hljs-keyword">import</span> Composer
<span class="hljs-keyword">from</span> docx <span class="hljs-keyword">import</span> Document

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">merge_docs</span>(<span class="hljs-params">output_path, *input_paths</span>):</span>

    base_doc = Document(input_paths[<span class="hljs-number">0</span>])
    composer = Composer(base_doc)


    <span class="hljs-keyword">for</span> file_path <span class="hljs-keyword">in</span> input_paths[<span class="hljs-number">1</span>:]:
        doc = Document(file_path)
        composer.append(doc)

    composer.save(output_path)
    print(<span class="hljs-string">f"Documents merged successfully into <span class="hljs-subst">{output_path}</span>"</span>)

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    output_file = <span class="hljs-string">"merged_document.docx"</span>
    input_files = [<span class="hljs-string">"doc1.docx"</span>, <span class="hljs-string">"doc2.docx"</span>, <span class="hljs-string">"doc3.docx"</span>]
    merge_docs(output_file, *input_files)
</code></pre>
<p>In this code:</p>
<ol>
<li><p><code>Composer</code> – Manages the merging process by taking an initial document and appending additional documents while retaining their formatting.</p>
</li>
<li><p><code>append</code> – Adds each subsequent document’s content to the base document, preserving the original layout and styles.</p>
</li>
<li><p><code>save</code> – Finalizes and saves the merged document to the specified output path.</p>
</li>
</ol>
<h3 id="heading-how-to-add-page-breaks-with-docxcompose">How to Add Page Breaks with <code>docxcompose</code></h3>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/Page_break">Page breaks</a> help maintain a clear separation between sections, enhancing the document's organization and readability.</p>
<p>With <code>docxcompose</code>, you can ensure that each appended document begins on a new page, which improves the final document’s structure and navigation.</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> docxcompose.composer <span class="hljs-keyword">import</span> Composer
<span class="hljs-keyword">from</span> docx <span class="hljs-keyword">import</span> Document

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">merge_docs_with_page_breaks</span>(<span class="hljs-params">output_path, *input_paths</span>):</span>

    base_doc = Document(input_paths[<span class="hljs-number">0</span>])
    composer = Composer(base_doc)


    <span class="hljs-keyword">for</span> file_path <span class="hljs-keyword">in</span> input_paths[<span class="hljs-number">1</span>:]:
        doc = Document(file_path)

        <span class="hljs-comment"># adding page break before merging each document</span>
        base_doc.add_page_break()
        composer.append(doc)

    composer.save(output_path)
    print(<span class="hljs-string">f"Documents merged successfully into <span class="hljs-subst">{output_path}</span>"</span>)

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    output_file = <span class="hljs-string">"merged_document_with_page_breaks.docx"</span>
    input_files = [<span class="hljs-string">"doc1.docx"</span>, <span class="hljs-string">"doc2.docx"</span>, <span class="hljs-string">"doc3.docx"</span>]
    merge_docs_with_page_breaks(output_file, *input_files)
</code></pre>
<p><strong>Note:</strong> You can also use the same method to <a target="_blank" href="https://www.docstomarkdown.pro/merge-multiple-google-docs-into-one-and-export/">merge multiple Google Docs into one</a> by first exporting the Google Docs as Word documents.</p>
<h2 id="heading-2-how-to-merge-documents-with-pypandoc">2. How to Merge Documents with <code>pypandoc</code></h2>
<p><a target="_blank" href="https://pypi.org/project/pypandoc/"><code>pypandoc</code></a> is a powerful tool that leverages <a target="_blank" href="https://www.freecodecamp.org/news/how-to-use-pandoc/">Pandoc</a> to convert and merge documents across a wide range of formats.</p>
<p>Pandoc is known for its versatility in handling document conversions, and <code>pypandoc</code> extends this capability to Python, enabling the integration of documents from different sources and formats.</p>
<p><strong>Key Features:</strong></p>
<ol>
<li><p><strong>Cross-Format Conversion</strong> – Supports conversion between various formats such as DOCX, Markdown, HTML, and more.</p>
</li>
<li><p><strong>Unified Output</strong> – Allows you to merge content from diverse formats into a single DOCX file, making it useful for integrating documents created with different tools.</p>
</li>
<li><p><strong>Text-Based Merging</strong> – Converts documents to plain text for merging and then back to DOCX, simplifying the integration process.</p>
</li>
<li><p><strong>Processing Time</strong> – <code>pypandoc</code> is generally faster than <code>docxcompose</code> for merging documents, as it uses Pandoc's conversion capabilities to simplify the merging process. But it may be slower for very large documents or those with complex formatting.</p>
</li>
<li><p><strong>Memory Usage</strong> – <code>pypandoc</code> requires less memory usage compared to <code>docxcompose</code>, as it converts documents to plain text before merging, reducing the memory footprint.</p>
</li>
</ol>
<h3 id="heading-pypandoc-use-case"><code>pypandoc</code> Use Case</h3>
<p>Use <code>pypandoc</code> when:</p>
<ol>
<li><p>You need to merge documents in different formats (for example, DOCX, Markdown, HTML) into a single Word file.</p>
</li>
<li><p>You are working with content from various sources and need to produce a unified output.</p>
</li>
<li><p>You require a flexible solution for document integration that handles format conversions.</p>
</li>
</ol>
<h3 id="heading-how-to-install-pypandoc">How to Install <code>pypandoc</code></h3>
<p>Install <code>pypandoc</code> using the following command:</p>
<pre><code class="lang-python">pip install pypandoc
</code></pre>
<h3 id="heading-example-code-1">Example Code</h3>
<p>Here’s a Python script that uses <code>pypandoc</code> to merge documents from different formats into a single DOCX file:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> pypandoc
<span class="hljs-keyword">import</span> os

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">merge_docs</span>(<span class="hljs-params">output_path, *input_paths</span>):</span>
    all_text = <span class="hljs-string">""</span>
    <span class="hljs-keyword">for</span> file_path <span class="hljs-keyword">in</span> input_paths:
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> os.path.isfile(file_path):
            print(<span class="hljs-string">f"File not found: <span class="hljs-subst">{file_path}</span>"</span>)
            <span class="hljs-keyword">continue</span>

        text = pypandoc.convert_file(file_path, <span class="hljs-string">'plain'</span>)
        all_text += text + <span class="hljs-string">"\n\n"</span>


    doc = pypandoc.convert_text(all_text, <span class="hljs-string">'docx'</span>, format=<span class="hljs-string">'md'</span>)
    <span class="hljs-keyword">with</span> open(output_path, <span class="hljs-string">'wb'</span>) <span class="hljs-keyword">as</span> f:
        f.write(doc)

    print(<span class="hljs-string">f"Documents merged successfully into <span class="hljs-subst">{output_path}</span>"</span>)

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    output_file = <span class="hljs-string">"merged_document.docx"</span>
    input_files = [<span class="hljs-string">"doc1.md"</span>, <span class="hljs-string">"doc2.html"</span>, <span class="hljs-string">"doc3.docx"</span>]
    merge_docs(output_file, *input_files)
</code></pre>
<p>In this code:</p>
<ol>
<li><p><code>convert_file</code> – Converts each document to plain text, which simplifies the merging process by removing formatting.</p>
</li>
<li><p><code>convert_text</code> – Converts the combined plain text back to DOCX format, allowing for a unified final document.</p>
</li>
</ol>
<p><code>pypandoc</code> also allows multiple other document operations such as converting DOCX files to Markdown, enabling you to automate publishing Word or <a target="_blank" href="https://workspace.google.com/marketplace/app/docs_to_wordpress_pro/346830534164">Google Docs to WordPress</a> or any other CMS.</p>
<p><strong>Caution:</strong> While <code>pypandoc</code> is effective for converting and merging documents, be aware that formatting may be lost during the process. The text-based merging approach <strong>may not</strong> preserve all original styles, headers, or other formatting details from the source documents.</p>
<h2 id="heading-3-how-to-merge-documents-with-python-docx">3. How to Merge Documents with <code>python-docx</code></h2>
<p><a target="_blank" href="https://pypi.org/project/python-docx/"><code>python-docx</code></a> is a widely used library for creating, reading, and <a target="_blank" href="https://www.freecodecamp.org/news/how-to-delete-a-page-in-word-remove-blank-or-extra-pages/">manipulating DOCX files</a>. While it does not specialize in merging, you can still effectively use it for basic merging tasks. This library is suitable for straightforward document manipulation and merging without the need for complex formatting preservation.</p>
<p><strong>Key Features:</strong></p>
<ol>
<li><p><strong>Basic Document Handling</strong> – Allows you to create, read, and edit DOCX files.</p>
</li>
<li><p><strong>Simple Merging</strong> – Can be used for basic merging tasks where advanced formatting is not a primary concern.</p>
</li>
<li><p><strong>Ease of Use</strong> – Provides a simple API for document manipulation, making it accessible for basic needs.</p>
</li>
<li><p><strong>Processing Time</strong> – This is the fastest method for merging documents, as it uses a simple, straightforward approach to combine documents. But it may not preserve complex formatting and styles.</p>
</li>
<li><p><strong>Memory Usage</strong> – This requires the least amount of memory usage among the three methods, as it only stores the merged document in memory temporarily before saving it to disk.</p>
</li>
</ol>
<h3 id="heading-python-docx-use-case"><code>python-docx</code> Use Case</h3>
<p>Use <code>python-docx</code> when:</p>
<ol>
<li><p>You need a simple solution for merging DOCX files without complex formatting requirements.</p>
</li>
<li><p>The documents you are merging do not include advanced elements like custom headers, footers, or styles.</p>
</li>
<li><p>You are looking for a straightforward approach to combine DOCX files with minimal setup.</p>
</li>
</ol>
<h3 id="heading-how-to-install-python-docx">How to Install <code>python-docx</code></h3>
<p>To use <code>python-docx</code>, install the library with:</p>
<pre><code class="lang-python">pip install python-docx
</code></pre>
<h3 id="heading-example-code-2">Example Code</h3>
<p>Here’s a Python script that uses <code>python-docx</code> to merge DOCX files:</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> docx <span class="hljs-keyword">import</span> Document
<span class="hljs-keyword">import</span> os

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">merge_docs</span>(<span class="hljs-params">output_path, *input_paths</span>):</span>
    merged_doc = Document()

    <span class="hljs-keyword">for</span> file_path <span class="hljs-keyword">in</span> input_paths:
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> os.path.isfile(file_path):
            print(<span class="hljs-string">f"File not found: <span class="hljs-subst">{file_path}</span>"</span>)
            <span class="hljs-keyword">continue</span>

        doc = Document(file_path)
        <span class="hljs-keyword">for</span> element <span class="hljs-keyword">in</span> doc.element.body:
            merged_doc.element.body.append(element)

    merged_doc.save(output_path)
    print(<span class="hljs-string">f"Documents merged successfully into <span class="hljs-subst">{output_path}</span>"</span>)

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    output_file = <span class="hljs-string">"merged_document.docx"</span>
    input_files = [<span class="hljs-string">"doc1.docx"</span>, <span class="hljs-string">"doc2.docx"</span>, <span class="hljs-string">"doc3.docx"</span>]
    merge_docs(output_file, *input_files)
</code></pre>
<p>In this code:</p>
<ol>
<li><p><code>Document</code> – Represents a Word document in Python.</p>
</li>
<li><p><code>element.body.append</code> – Appends the content of each document to the merged document.</p>
</li>
<li><p><code>save</code> – Saves the final merged document to the specified path.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Each method for merging Word documents in Python offers unique advantages depending on your specific needs:</p>
<ol>
<li><p><code>docxcompose</code> preserves complex formatting and styles, but may be slower for large documents and requires moderate memory usage.</p>
</li>
<li><p><code>pypandoc</code> is ideal for combining documents in different formats, but may lose some formatting and require less memory usage.</p>
</li>
<li><p><code>python-docx</code> is suitable for simple merging tasks with basic formatting needs, and is the fastest method with the least memory usage.</p>
</li>
</ol>
<p>When choosing a method, consider not only the complexity of your documents but also the performance and memory requirements of your application.</p>
<ul>
<li><p>If you need to merge large documents with complex formatting, <code>docxcompose</code> may be the best choice, but be prepared for slower processing times.</p>
</li>
<li><p>If you need to integrate content from various sources, <code>pypandoc</code> is a good option, but be aware of potential formatting losses.</p>
</li>
</ul>
<p>For simple merging tasks, <code>python-docx</code> is a fast and lightweight solution.</p>
<p>By considering the strengths and weaknesses of each method, including performance and memory considerations, you can make an informed decision and choose the best approach for your specific use case. This will ensure you experience an efficient and effective document merging processes.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Write Good Documentation ]]>
                </title>
                <description>
                    <![CDATA[ In this article, I'll discuss the secret to never forgetting how your project works, in three steps. If you’ve ever half-written a software project before taking a few days off, this is the article you’ll discover you needed when you reopen that IDE.... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-write-good-documentation/</link>
                <guid isPermaLink="false">66bd8f5bc89bd16700302df8</guid>
                
                    <category>
                        <![CDATA[ docs ]]>
                    </category>
                
                    <category>
                        <![CDATA[ documentation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Infrastructure as code ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Victoria Drake ]]>
                </dc:creator>
                <pubDate>Mon, 21 Dec 2020 21:00:58 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/12/cover-1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this article, I'll discuss the secret to never forgetting how your project works, in three steps.</p>
<p>If you’ve ever half-written a software project before taking a few days off, this is the article you’ll discover you needed when you reopen that IDE.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/12/friday-monday.png" alt="Your project on Friday (a finished puzzle) vs Monday (a pile of puzzle pieces) comic" width="600" height="400" loading="lazy">
<em>Don't worry, it'll all come together by Friday again... (Comic by author)</em></p>
<p>In the technology teams I lead, we make a constant effort to document all the things. Documentation lives alongside the code as an equal player. </p>
<p>This helps ensure that no one needs to make assumptions about how something works, or is calling lengthy meetings to gain working knowledge of a feature. Good documentation saves us a lot of time and hassle.</p>
<p>That said, and contrary to popular belief, the most valuable software documentation is not primarily written for other people. As I said in this well-received tweet:</p>
<blockquote>
<p>The secret to good documentation is to write it while you're writing the code. You are your first audience. Explain what you're doing to yourself. Future you will thank you!</p>
<p>— Victoria Drake <a target="_blank" href="https://twitter.com/victoriadotdev/status/1331262801797652483?ref_src=twsrc%5Etfw">November 24, 2020</a></p>
</blockquote>
<p>Here are three concrete steps you can take to write good documentation before it’s too late.</p>
<h2 id="heading-1-start-with-accurate-notes">1. Start with accurate notes</h2>
<p>As you work out ideas in code, ensure you don’t soon forget important details by starting with accurate notes. While you will want to explain things to yourself in long-form later, short-form notes will suffice to capture details without interrupting your coding session flow.</p>
<p>Keep a document open alongside your code and write down things like commands, decisions, and sources you use. This can include:</p>
<ul>
<li>Terminal commands you typed in</li>
<li>Why you chose a particular method over another</li>
<li>Links you visited for help or _cough_copy-paste<em>cough</em> inspiration</li>
<li>The order in which you did things</li>
</ul>
<p>Don’t worry about full sentences at this point. Just ensure you accurately capture context, relevant code snippets, and helpful URLs. It can also be helpful to turn on any auto-save option available.</p>
<h2 id="heading-2-explain-decisions-in-long-form">2. Explain decisions in long form</h2>
<p>The ideal time to tackle this step is when you take a break from coding, but before you completely go out to lunch on whatever it is you’re working on at the moment. </p>
<p>You want to ensure that context, ideas, and decisions are all still fresh in your mind when you explain them to yourself.</p>
<p>Go over the short-form notes you took and start expanding them into conversational writing. Be your own rubber duck. Describe what you’re doing as if you were teaching it to someone else. You might cover topics such as:</p>
<ul>
<li>Quirky-looking decisions: “I would normally do it this way, but I chose to do something different because…”</li>
<li>Challenges you ran into and how you overcame them</li>
<li>Architectural decisions that support your project goals</li>
</ul>
<p>Stick to the main points. Long-form writing doesn’t mean you’ll be paid by the word! Just use full sentences, and write as if explaining your project to a colleague. You’re explaining to future you, after all.</p>
<h2 id="heading-3-dont-neglect-prerequisite-knowledge">3. Don’t neglect prerequisite knowledge</h2>
<p>This step is best done after a long lunch break, or even the next day (but probably not two). Re-read your document and fill in any blanks that become apparent after putting some distance between yourself and the project.</p>
<p>Take extra care to fill in or at least link to prerequisite knowledge, especially if you frequently use different languages or tools. Even an action as small as pasting in a link to the API documentation you used can save hours of future searching.</p>
<p>Write down or link to READMEs, installation steps, and relevant support issues. For frequently performed command-line actions, you can use a <a target="_blank" href="https://victoria.dev/blog/how-to-create-a-self-documenting-makefile/">self-documenting Makefile</a> to avoid having to <code>man</code> common tasks each time you come back to a project.</p>
<p>It’s easy to forget supporting details after even just a short break from your project. Capture anything you found helpful this time around.</p>
<h2 id="heading-document-all-the-things">Document all the things!</h2>
<p>The next time you catch yourself thinking, “I’m sure I’ll remember this part, no need to write it down,” just recall this emoji: 🤦‍♀️</p>
<p>Software projects are made up of a lot more than just their code. To best set up your future self for success, document all the things! Whether it’s a process you’ve established, Infrastructure as Code, or a fleeting future roadmap idea — write it down! Future you will thank you for it.</p>
<p>If you enjoyed this post, I'd love to know. Join the thousands of people who learn along with me on <a target="_blank" href="https://victoria.dev/">victoria.dev</a>! Visit and subscribe for more about building your coding skill stack.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to make your future self happy by writing good docs ]]>
                </title>
                <description>
                    <![CDATA[ By Gabriele Cimato Or how to be less miserable when dusting off an old code base This is a little overview of common problems faced when working on a new or old project. Sometimes making a little effort up front can save you time and energy down the... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-make-your-future-self-happy-by-writing-good-docs-f41fba2d2dab/</link>
                <guid isPermaLink="false">66c3537fb3da455a9c10dc08</guid>
                
                    <category>
                        <![CDATA[ docs ]]>
                    </category>
                
                    <category>
                        <![CDATA[ engineering ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Productivity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 18 Feb 2019 17:04:52 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*bJKzkdJMBUhmDAnhwmpNsQ.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Gabriele Cimato</p>
<h4 id="heading-or-how-to-be-less-miserable-when-dusting-off-an-old-code-base">Or how to be less miserable when dusting off an old code base</h4>
<p><img src="https://cdn-media-1.freecodecamp.org/images/RH-mg3pmhVjtkFBzYfiWrfexlQZjf5KnUshr" alt="Image" width="800" height="520" loading="lazy"></p>
<p>This is a little overview of common problems faced when working on a new or old project. Sometimes making a little effort up front can save you time and energy down the line. Writing good docs is like getting ready for your future self to high-five you ✋! We’ll see a silly example and a few recommended practices to get started with a good <code>README.md</code>.</p>
<h3 id="heading-the-struggle">The Struggle</h3>
<p>I’m almost certain that in your career, or in your everyday life, you faced a situation before that makes you think:</p>
<blockquote>
<p>“This problem looks familiar, I’m pretty sure I solved it before. If only I could remember how I did it!”</p>
</blockquote>
<p>Especially coming from an engineering perspective this happens quite a lot. Repeated patterns, functions or bugs we’ve met before that require us to go through the exact same past effort to overcome an issue. Sometimes we are willing to do it again, so we go ahead and figure it out once more. Some other times though…</p>
<h3 id="heading-an-example">An example</h3>
<p>I lead the R&amp;D department at Hutch and we often have to dig deep into new and unseen technologies, frameworks or languages. You try and experiment a lot and can’t expect to remember everything you interact with. You work on something for a couple months then, once you’re done, switch to something very different. Or maybe you just work on the next step in a pipeline.</p>
<p>Then, when you least expect it, it happens. You have to go back to that framework you used 3 months before to make a change. You give it a look, a puzzled one ?.</p>
<blockquote>
<p>“Oh, actually I remember this. To make it behave this other way I go here…change this…and voilà!”</p>
</blockquote>
<p>At that moment you feel pretty good about it. You were able to recollect how things worked. You’re even proud of yourself for leaving simple docs on many of the functions you wrote many moons before. Then with a light touch of your mouse, you run the project and…</p>
<p>⛔ <strong>ERROR! The main frame has some cowbells directed towards Mars, this is not allowed.</strong></p>
<p>? Yikes! This looks very cryptic. You take a look at the code you changed and, well…you try to run it again. Maybe something will automatically change. Maybe looking at it again had some quantum effect of some sort. Nope.</p>
<p>⛔ <strong>ERROR! The main frame has some cowbells directed towards Mars, this is not allowed.</strong></p>
<p>You then read through the comments or the docs. Nothing mentions this error, nothing points you in the right direction. This error is so distinctive that you’re sure you saw it before, and also solved it before. As daunting as it feels, you have to figure it out…again!</p>
<p>You start googling the problem and notice some previously visited links.</p>
<blockquote>
<p>“Great! This link is probably the one that helped me with the error…phew. Crisis averted!”</p>
</blockquote>
<p>You then scroll the page and, oh no! More…many more visited links. So now you have no idea which one led to a solution if any. And so the search continues until eventually, you figure it out — minutes, hours or even days later.</p>
<h3 id="heading-good-documentation-covers-more-than-just-happy-paths">Good documentation covers more than just happy paths ?</h3>
<p>I learned this the hard way. Multiple times. It’s often easy, although admirable, to add docs to your functions/methods/classes with the assumption that everything will work well.</p>
<p>I always try to make life easier for whoever will dig into my code. That includes future me! So I diligently add docs to almost all of my functions but the trivial ones. As many have said for decades:</p>
<blockquote>
<p>Your comments should explain the <strong>why</strong> more than the <strong>what</strong>.</p>
</blockquote>
<p>Your code should be “<em>self-documenting”</em> so that any added comment addressing the “what” would result redundant.</p>
<p>In all fairness, I tend to add comments even for the “what”, only when I know a function is either long or somehow intricate. Adding a few lines of comments would allow me to skip examining every line of code. This has been helpful countless times and I absolutely recommend it!</p>
<p>But documentation is not just lines of comments on a function. Good documentation is a well written <code>README.md</code>. In some scenarios even a full-fledged dedicated website for bigger projects (see <a target="_blank" href="https://reactjs.org/docs/getting-started.html">React</a>, <a target="_blank" href="https://redux.js.org/introduction/getting-started">Redux</a>, <a target="_blank" href="https://vuejs.org/v2/guide/">Vue</a>, <a target="_blank" href="https://docs.slatejs.org/">Slate</a>, …).</p>
<p>The projects mentioned are all open source. Teams are basically compelled to go in greater detail to help people start using their framework or library (and have been doing a great job in that regard!). But what about smaller private projects? What about those projects that will only live within the company (no matter what the size of the team is)? And what about all those issues that are not purely code related?</p>
<p>More often than not we tend to skip the <code>README.md</code> file or dismiss it with a few lines only. I’ve been following a simple yet powerful practice to make this task less intimidating and help go beyond the happy paths.</p>
<h3 id="heading-a-basic-approach-to-creating-a-good-readme">A basic approach to creating a good README</h3>
<p>When mentioning “happy paths” I refer to the practice of assuming everything will run smoothly. This means we are only addressing each step of a process as if it will always succeed.</p>
<p>Unfortunately, that is not always the case so, how can we make our lives better? How do we make sure that even the not-so-happy paths are covered?</p>
<p>Here are a few suggestions:</p>
<ul>
<li>Start by writing down a few lines about what the project is about and <strong>what problem you are trying to solve.</strong> This helps you, and whoever goes through it, understanding the intent of the project.</li>
<li>As you go about setting everything up, make sure you add each step to the <code>README.md</code>. It doesn’t have to be well formatted and phrased, it just needs to be there for now. This usually comes in the form of installation instructions.</li>
<li>If at any time you face an error of any sort, add a section at the bottom. You can call it <strong>Common Errors.</strong> There you add some details about the error you faced and how you solved it. One crucial thing I like to do here is add links to the source of the solution (or anything that helped me get there).</li>
<li>When I reach a stable point in the project I try to install it on a new machine (if it’s a possibility). The goal here is to <strong>ensure that the set-up steps we listed before are correct</strong> and work as expected.</li>
<li>Most importantly, you need to have a section answering the question: <strong>how do I use/run this project?</strong> This should be as clear as possible, so put some effort into it! Sometimes, though, you can’t answer this question until later on. You can wait until you are in a working/running state to update the <code>README.md</code> .</li>
<li>Put aside some time to <strong>review and clean</strong> up your <code>README.md</code> file. Most of the time you’ll probably need to <strong>update it</strong>.</li>
</ul>
<p>This is often enough for small size projects. For mid to large-sized ones it can be a starting point to develop some good practices. Talk about it with the rest of the team and agree on a common approach that will make everyone happy. Keep in mind that <strong>maintaining the docs up to date is crucial!</strong> Hold each other accountable for it and after the initial effort, it’ll become natural, just like a simple refactoring!</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Writing good docs involves maintaining a good <code>README.md</code> and documenting the <strong>whys</strong> in your code more than the <strong>what</strong>.</p>
<p>If you make a small effort and incrementally build up a good <code>README.md</code> it will feel less intimidating. Not only will it make your life better in the future, but it will help anyone else contributing.</p>
<p>Don’t cover only the happy paths expecting everything will work, also cover eventual errors that you face or any issue a newcomer might face. Keep a dedicated section for this.</p>
<p><strong>Bonus:</strong> when estimating your work with a PM, take into account the effort required to write/update the docs. Don’t underestimate the fact that good docs require a good amount of time. But that time is very well spent!</p>
<p>? Hi, I’m Gabri! I love innovation and lead R&amp;D at Hutch. I also love React, Javascript and Machine Learning (among a million other things). You can follow me on twitter @<a target="_blank" href="https://twitter.com/GabriOnTheRocks"><strong>G</strong>abriOnTheRocks</a> and on GitHub @<a target="_blank" href="https://github.com/Gabri3l">Gabri3l</a> . Leave a comment if you have any other recommendation that you’d like to share, or send a DM on Twitter if you have any question!</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
