Commit Graph

1075 Commits

Author SHA1 Message Date
Veikka Tuominen
7199d7c777 split @qualCast into @constCast and @volatileCast 2023-02-15 01:43:57 +02:00
Manlio Perillo
5894be94c8 langref: make more examples testable
Some examples using {#syntax_block|zig|...#} either have a valid syntax
or it is easy to make the syntax valid.  Update these example to use
{#code_begin|syntax|...#}.

Remove extra whitespace in the error_union_parsing_u64.zig example.

Replace size_t with usize in the call_malloc_from_zig.zig example.
2023-02-13 16:21:54 +02:00
ee7
289e8fab79 langref, tools: rename --single-threaded to -fsingle-threaded
Commit 40f5e5dfc6 ("CLI: introduce -fsingle-threaded/
-fno-single-threaded", 2021-12-01) removed the `--single-threaded`
option, but didn't update all mentions of it.

    $ zig version
    0.11.0-dev.1568+c9b957c93
    $ zig build-exe --help | grep single
      -fsingle-threaded         Code assumes there is only one thread
      -fno-single-threaded      Code may not assume there is only one thread
    $ zig build-exe --single-threaded foo.zig
    error: unrecognized parameter: '--single-threaded'
2023-02-04 23:24:07 +02:00
Manlio Perillo
c181ba1022 langref: remove link to closed issue #4026
In the math builtin functions documentation, remove the link to issue
https://github.com/ziglang/zig/issues/4026, since it was closed by
https://github.com/ziglang/zig/pull/11532.
2023-02-03 14:49:17 +02:00
Andrew Kelley
6b7ad22981
Merge pull request #14477 from Vexu/fixes
Improve `@ptrCast` errors, fix some bugs
2023-02-01 23:31:52 -05:00
Josh Holland
1fba88450d langref: add paragraph and examples about indexing non-ASCII strings
PR #10610 addressed most of the points from #1854.  This
additional paragraph and examples covers the OMISSIONS section
clarifying issues about indexing into non-ASCII strings (whether valid
UTF-8 or not).  I think this finally closes #1854.
2023-02-01 21:46:46 +02:00
Andrew Kelley
9a29f4e038 langref updates for new std.Build API 2023-01-31 15:09:35 -07:00
Andrew Kelley
36e2d992dd combine std.build and std.build.Builder into std.Build
I've been wanting to do this for along time.
2023-01-31 15:09:35 -07:00
Andrew Kelley
73cf7b6429 update build.zig API usage 2023-01-31 15:09:35 -07:00
Veikka Tuominen
f16c10a86b implement @qualCast 2023-01-30 18:55:57 +02:00
Veikka Tuominen
a9785fe8ee Sema: add helpful notes to invalid @ptrCast operations
Closes #14474
2023-01-30 15:20:16 +02:00
Manlio Perillo
fcef728b9b langref: make "Type Coercion" subsections more consistent
In the "Type Coercion" section, rename:
  - Coercion Float to Int => Float to Int
  - unions and enums => Unions and Enums
  - tuples to arrays => Tuples to Arrays
2023-01-25 23:29:25 +02:00
Manlio Perillo
21d9f0c2a1 langref: add missing dot at the end of the paragraph
In the "C Variadic Functions" section, add a missing dot at the end of
the paragraph before the test_defining_variadic_function.zig example.
2023-01-25 16:09:17 -05:00
Manlio Perillo
d64dd75e34 langref: update the documentation of @Type
@Type is currently available for Functions.
2023-01-25 18:15:56 +02:00
Manlio Perillo
33e5a84706 langref: improve test_coerce_unions_enums.zig
Add more coercion examples to test_coerce_unions_enums.zig in the
"Type Coercion: unions and enums" section.
2023-01-25 17:03:39 +02:00
Manlio Perillo
8de46d1d7d langref: move paragraph inside the p element
In the "C Translation CLI" section, move the paragraph inside the p
element.

The current HTML is valid, but, as an example, a paragraph outside a p
element is not handled correctly by the browser Inspect tool.
2023-01-25 17:01:43 +02:00
Manlio Perillo
81035b7eb3 langref: remove extra curly bracket in the CSS
In commit 3542dbf0ea (langref: add section numbers) I accidentally
added an extra closing curly bracket at the end of the style element.

Sorry for not validating the HTML file before creating the PR.
2023-01-23 15:51:17 -05:00
Manlio Perillo
ce6de2df82 docgen: make the name required in the Code node
Update the genToc funtion to make the name required in the Code node,
and add an additional optional field for the expected error, to use with
test_err, test_safety and obj_err.

Update langref.html.in to ensure all code blocks have a name that

  - is unique, so that a doctest can be identified by it
  - is descriptive

For test, test_err and test_safefy, ensure that the doctest name starts
with "test_", excluding doctests in the "Zig Test" section and doctests
that are imported by other doctests.

Ensure that the indentation of code_begin and code_end blocks are
consistent.

Fix a typo in pointer_arthemtic.
2023-01-23 15:14:24 +02:00
Andrew Kelley
3cb1ab0e05 langref: point 0.10.0 nav link to 0.10.1 2023-01-22 18:19:26 -07:00
Manlio Perillo
efbb6128bb langref: always start code on a separate line in a syntax_block
In a syntax_block the code always start on a separate code, expect for
C, JavaScript, Peg and with Zig inline assembly.

Ensure that the code starts on a separate line, even in cases where
there is only one line.

Ensure that the end_syntax_block is always on a separate line and that
the indentation is consistent.
2023-01-19 19:10:01 +02:00
Manlio Perillo
72c09b7b3b langref: use the term tuple in the Hello World section
In the Hello World section, replace the term "anonymous struct literal"
with tuple, when documenting the second argument of stdout.print().
2023-01-18 15:33:58 +02:00
Manlio Perillo
06e9b2c4e3 langref: document UTF-8 BOM handling
The current compiler ignores the UTF-8 BOM if it is at the start of the
file, and disallows it anywhere else.  Document it in the Source Encoding
section.
2023-01-17 20:07:53 +02:00
Manlio Perillo
0973f36389 langref: add the new addrspace keyword
Add the new addrspace keyword in the Keyword Reference section, without
documentation.

Move the linksection keyword in order to keep the keywords list sorted.
2023-01-17 20:04:37 +02:00
Manlio Perillo
fde57330fa docgen: improve command-line argument parsing
Implement a simple command-line argument parser, adapted from the Zig
compiler implementation.

Promote the zig positional argument to an option.
2023-01-13 17:24:10 +01:00
Manlio Perillo
c5351a8d49 docgen: remove unnecessary and incorrect deallocations
The deallocations of the process arguments are unnecessary, since the
memory will be deallocated by arena.deinit().

The deallocations are incorrect, since ArgIterator.next() returns a
slice pointing to the iterator's internal buffer, that should be
deallocated with args_it.deinit().
2023-01-13 15:20:00 +01:00
Techatrix
0a8b7ad368
langref: fix unclosed and lonely tag (#14250) 2023-01-10 18:02:29 -05:00
Veikka Tuominen
83fd45d820
Merge pull request #13786 from ziglang/tty-detection
stage2: make --color on affect progress bar too
2023-01-04 16:54:46 +02:00
Veikka Tuominen
95fe23f572 docgen: handle 'K' and 'D' escape codes 2023-01-03 14:03:43 +02:00
Evin Yulo
fc07e1a267 Document tuple syntax
Closes #13837
2023-01-03 13:29:27 +02:00
Veikka Tuominen
8a6295fcba AstGen: make type sentinel expressions implicitly comptime 2022-12-29 12:43:02 +02:00
Veikka Tuominen
622311fb9a update uses of overflow arithmetic builtins 2022-12-27 15:13:14 +02:00
Veikka Tuominen
af9a9a1374 zig fmt: improve handling of comptime tuple fields 2022-12-27 13:52:37 +02:00
zooster
547e3684be langref: more explicitly document how enum overriding works 2022-12-27 12:53:41 +02:00
Veikka Tuominen
0b859831ad update grammar in langref
Closes #14072
2022-12-26 16:36:29 +02:00
Manlio Perillo
3542dbf0ea langref: add section numbers
When reading a document with nested sections, it is not easy to discover
the depth of the current section.

Add support for nested section numbers, from the h2 to the h4 heading,
in the format "lv1. ", "lv1.lv2. ", "lv1.lv2.lv3. ".  The "Zig Version"
and "Table of Content" sections are excluded.

The section numbers are implemented in CSS, with the CSS rules declared
inside a @media rule.  Currently the @media rule targets all media.
2022-12-19 21:51:23 +02:00
Andrew Kelley
aca9c74e80
Merge pull request #13914 from Vexu/variadic
implement defining C variadic functions
2022-12-18 16:24:13 -05:00
Veikka Tuominen
40ed6ae846
Merge pull request #13930 from r00ster91/renamings
std.builtin: renamings
2022-12-18 19:33:15 +02:00
Evin Yulo
9cc49548aa langref: remove incorrect use of term 'literal' 2022-12-18 01:55:09 +02:00
r00ster91
aac2d6b56f std.builtin: rename Type.UnionField and Type.StructField's field_type to type 2022-12-17 14:11:33 +01:00
r00ster91
7350ea3e2d std.builtin: rename Type.Fn's args to params
This was a poor naming choice; these are parameters, not arguments.
Parameters specify what kind of arguments are expected, whereas the arguments are the actual values passed.
2022-12-17 14:11:33 +01:00
r00ster91
20d3fd901e std.builtin: rename Type.Fn.Param's arg_type to type
It's the type of a parameter, not an argument, but the prefix is redundant either way.
2022-12-17 14:11:33 +01:00
Veikka Tuominen
9bb1104e37 implement defining C variadic functions 2022-12-17 13:22:09 +02:00
Andrew Kelley
6378644d4e
Merge pull request #13907 from Vexu/call-merge
Remove `stack` option from `@call`
2022-12-13 18:15:18 -05:00
Evin Yulo
02b4ea71e3 Improve tagged union documentation
closes #13870
2022-12-13 15:11:43 -05:00
Manlio Perillo
35c6fe665c langref: document extern variadic functions
Add a new subsection within the C section, documenting extern variadic
functions.
2022-12-13 15:09:08 -05:00
Manlio Perillo
6486ee9fc7 langref: remove the trailing slash from the link element
A self-closing tag for void elements like link is only required under
XHTML 1.0.

See https://developer.mozilla.org/en-US/docs/Glossary/Void_element#self-closing_tags.
2022-12-13 15:02:48 -05:00
Manlio Perillo
17d85a72c4
langref: add missing ReleaseSmall when describing unreachable (#13909)
Add a missing ReleaseSmall when describing unreachable in the try
section and the unreachable entry in the Keyword Reference section.

Additionally, transform Debug, ReleaseSafe, ReleaseFast and ReleaseSmall
into links in the try section.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2022-12-13 15:02:17 -05:00
Manlio Perillo
89a9e927ad langref: improve the test_fn_reflection.zig doctest
Currently, the test_fn_reflection.zig doctest has an example of
.Fn.is_var_args.  This example can confuse the reader, since there is no
documentation about variadic functions and is_var_args is mainly used in
the compiler.

Remove the example with .Fn.is_var_args and add instead examples with
.Fn.return_type and .Fn.is_generic.
2022-12-13 15:00:42 -05:00
Manlio Perillo
1d5368fa35 langref: fix the slice_bounds.zig doctest
In the slice_bounds.zig doctest, the code "const slice = array[2..4]" is
incorrect, since the actual type is a pointer to an array, instead of a
slice.

Use a runtime know value to slice the array.
2022-12-13 14:59:46 -05:00
Manlio Perillo
21dafd7a54
langref: update comments in the slices.zig doctest (#13819)
In the slices.zig doctest, the code
`const all_together_slice = all_together[0..]` is incorrect, since the
actual type is a pointer to an array, instead of a slice.

Use a runtime-known value to slice the array.

In the next "slice pointer" test, clarify that slicing a slice to
produce a pointer to an array, requires comptime-known indexes, not just
constant indexes.
2022-12-13 14:58:52 -05:00