Skip to content

Improve Configuration and Validation sections of the docs#989

Merged
pedro-psb merged 5 commits intodynaconf:masterfrom
sebastian-correa:doc-improve-validation
Sep 15, 2023
Merged

Improve Configuration and Validation sections of the docs#989
pedro-psb merged 5 commits intodynaconf:masterfrom
sebastian-correa:doc-improve-validation

Conversation

@sebastian-correa
Copy link
Copy Markdown
Collaborator

Summary

Fixes #911 and #968 by adding documentation on some Dynaconf parameters and reworking the Validation section of the docs.

Details

Not much detail to give, as context is present in the 2 linked issues.

Aside from the obvious additions to configuration.md and validation.md, I updated the Pyhon version in CONTRIBUTING.md to 3.8+ and added .DS_Store file to .gitignore. In particular, any of these 2 unrelated changes could be dropped from this PR if needed :).

Questions

  1. Links between Markdown files don't seem to work on my local docs (make docs). Did I do something wrong or do they get fixed when deployed to the web?

Notes

Please feel free to ask any changes in this PR. The idea is to improve Dynaconf.

@netlify
Copy link
Copy Markdown

netlify bot commented Aug 25, 2023

Deploy Preview for dynaconf ready!

Name Link
🔨 Latest commit 7ac96f7
🔍 Latest deploy log https://app.netlify.com/sites/dynaconf/deploys/6504a5b3e51de7000874def4
😎 Deploy Preview https://deploy-preview-989--dynaconf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sebastian-correa sebastian-correa changed the title Improve Improve Configuration and Validation sections of the docs Aug 25, 2023
@sebastian-correa
Copy link
Copy Markdown
Collaborator Author

Maybe I have to do absolute links (without the ./ at the start?

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 26, 2023

Codecov Report

Merging #989 (7ac96f7) into master (c5d9f2f) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #989   +/-   ##
=======================================
  Coverage   98.70%   98.70%           
=======================================
  Files          23       23           
  Lines        2242     2242           
=======================================
  Hits         2213     2213           
  Misses         29       29           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Copy Markdown
Member

@pedro-psb pedro-psb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking way better. I'm opinionated on some small things, but feel free to disagree if you have different motivations. And as I've said before, the grammar/type checker is better than me on catching typos, so I didn't bother with this too much.

)
```

<h4>Trigger manually</h4>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this information about keys is good, but it might be a best fit as first thing on the Usage section (along with some general info about a Validator object).


... (overview)

Usage

To define validation rules, you must create Validator objects, which are constructed using keys (positional arguments) and rules (kwargs):

Validator("AGE", gte=20, lte=80) # multiple rules
Validator("NAME", "VERSION", "PORT", must_exist=True) # multiple keys
Validator("DB.PORT", eq=8080) # keys with dot-path notation

There are some different ways to use them, as we'll see.

... (on instatiation)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. What's the go-to section that explains that Dynaconf can handle weird keys? Like dotted lookups, the difference between upper and lower case, keys with __, and such? Maybe we should link it here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure there if there is a single place where this is presented.

@sebastian-correa
Copy link
Copy Markdown
Collaborator Author

sebastian-correa commented Sep 4, 2023

Thanks @pedro-psb for your input and patience. I pushed some changes, you can look at the diff here.

Please don't hesitate to re-ask for changes, and please mark as solved any discussions you think should be closed.

Edit: tried to fix the links. We'll see how that went.

Copy link
Copy Markdown
Member

@pedro-psb pedro-psb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good after the link fix. You can check if it works by running the mkdocs local server or in the Netlify comment (there is a link to a live preview of the PR).


In practice, this forwards `validate_exclude` to the `exclude` kwarg during the validation step upon `Dynaconf` instantiation for all `Validator`s passed. Note that this setting has interaction with [`validate_only`](#validate_only).

Read more about it in the [selective validation](./validation#selective-validation) section.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dot causes the link to resolve as configuration/validation#selective-validation, causing it to break.
We should have a link health checker in the dev tool chain.


This setting only applies during `Dynaconf` instantiation. Further calls to `Dynaconf.validators.validate` will use the value passed to the `only` kwarg in that call.

In practice, this forwards `validate_only` to the `only` kwarg during the validation step upon `Dynaconf` instantiation for all `Validator`s passed. Note that this setting has interaction with [`validate_exclude`](#validate-exclude).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here #validation-exclude should be #validation_exclude, because it uses _ explicitly. The link should use - when it comes from a whitespace transformation (e.g, if it was validation exclude).

no validation will be triggered.

You can override this globally with the option [validate_on_update](/configuration/#validate_on_update) or
You can override this globally with the option [validate_on_update](/configuration/#validate-on-update) or
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, the original uses literal underscores. I didn't see this detail about dash-underscore on my previous review.

@pedro-psb pedro-psb added this to the 3.2.3 milestone Sep 5, 2023
@sebastian-correa
Copy link
Copy Markdown
Collaborator Author

Hey @pedro-psb, I'll look at your comments during the weekend. My bad with the links though, I could've sworn that I went through all of them :S.

The guide specified Python 3.6+ when Dynaconf is 3.8+.
@sebastian-correa
Copy link
Copy Markdown
Collaborator Author

sebastian-correa commented Sep 10, 2023

@pedro-psb sorry this is taking so long, I don't have much time mid-week to tackle this PR :S. I've now re-read and it looks like its better now. I'll look check all links from the dev deploy once it's ready.

Edit: Links seem to work. Also caught some other formatting issues. Let me know what you think! Also: rebased with master.

Rework structure as suggested by @pedro-psb in dynaconf#911, improve clarity in
the text and expand on some subsections.
Add sections on validate_only_current_env, validate_only and
validate_exclude.
@rochacbruno rochacbruno modified the milestones: 3.2.3, 3.2.4 Sep 11, 2023
Copy link
Copy Markdown
Member

@pedro-psb pedro-psb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastian-correa Don't need to apologize, I'm glad you took the effort to contribute!
It's good to go, we'll ship it in 3.2.4

@pedro-psb pedro-psb merged commit 99741a3 into dynaconf:master Sep 15, 2023
@sebastian-correa sebastian-correa deleted the doc-improve-validation branch September 16, 2023 23:55
pedro-psb added a commit to pedro-psb/dynaconf that referenced this pull request Oct 31, 2023
Shortlog of commit since last release:

    Bruno Rocha (2):
          Release version 3.2.3
          fix(env): allow underscore in env name dynaconf#1011 (dynaconf#1015)

    Jake Callahan (1):
          fix(vault): pin hvac minimum version

    Pedro Pessoa (3):
          fix(set): non-str key raising type error dynaconf#1005 (dynaconf#1008)
          fix(merge): dynaconf_merge=False on nested structures (dynaconf#1012)
          fix(cli): support for 'entrypoint-path' in FLASK_APP dynaconf#946 (dynaconf#1014)

    Sebastian Correa (1):
          doc(validation): Improve Configuration and Validation sections of the docs (dynaconf#989)

    Vladislav Sharapov (1):
          doc(envvars): Fix link to configuration page (dynaconf#1020)
pedro-psb added a commit to pedro-psb/dynaconf that referenced this pull request Nov 19, 2023
Shortlog of commit since last release:

    Bruno Rocha (2):
          Release version 3.2.3
          fix(env): allow underscore in env name dynaconf#1011 (dynaconf#1015)

    Jake Callahan (1):
          fix(vault): pin hvac minimum version

    Pedro Pessoa (3):
          fix(set): non-str key raising type error dynaconf#1005 (dynaconf#1008)
          fix(merge): dynaconf_merge=False on nested structures (dynaconf#1012)
          fix(cli): support for 'entrypoint-path' in FLASK_APP dynaconf#946 (dynaconf#1014)

    Sebastian Correa (1):
          doc(validation): Improve Configuration and Validation sections of the docs (dynaconf#989)

    Vladislav Sharapov (1):
          doc(envvars): Fix link to configuration page (dynaconf#1020)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] Docs: re-structure Validation Page hierarchy

3 participants